Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw error when paths option mapping empty array #9909

Merged
merged 2 commits into from
Jul 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,10 @@
"category": "Error",
"code": 5065
},
"Substitutions for pattern '{0}' shouldn't be an empty array.": {
"category": "Error",
"code": 5066
},
"Concatenate and emit output to single file.": {
"category": "Message",
"code": 6001
Expand Down Expand Up @@ -2800,11 +2804,11 @@
"category": "Error",
"code": 6133
},
"Report errors on unused locals.": {
"Report errors on unused locals.": {
"category": "Message",
"code": 6134
},
"Report errors on unused parameters.": {
"Report errors on unused parameters.": {
"category": "Message",
"code": 6135
},
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,9 @@ namespace ts {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key));
}
if (isArray(options.paths[key])) {
if (options.paths[key].length === 0) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key));
}
for (const subst of options.paths[key]) {
const typeOfSubst = typeof subst;
if (typeOfSubst === "string") {
Expand Down
6 changes: 6 additions & 0 deletions tests/baselines/reference/pathsValidation3.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
error TS5066: Substitutions for pattern 'foo' shouldn't be an empty array.


!!! error TS5066: Substitutions for pattern 'foo' shouldn't be an empty array.
==== tests/cases/compiler/a.ts (0 errors) ====
let x = 1;
5 changes: 5 additions & 0 deletions tests/baselines/reference/pathsValidation3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//// [a.ts]
let x = 1;

//// [a.js]
var x = 1;
12 changes: 12 additions & 0 deletions tests/cases/compiler/pathsValidation3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @filename: tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"foo": []
}
}
}

// @filename: a.ts
let x = 1;