Merge pull request #9909 from YuichiNukiyama/fix9772

throw error when paths option mapping empty array
This commit is contained in:
Mohamed Hegazy
2016-07-23 10:08:04 -07:00
committed by GitHub
5 changed files with 32 additions and 2 deletions
+6 -2
View File
@@ -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
@@ -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
},
+3
View File
@@ -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") {
@@ -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;
@@ -0,0 +1,5 @@
//// [a.ts]
let x = 1;
//// [a.js]
var x = 1;
+12
View File
@@ -0,0 +1,12 @@
// @filename: tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"foo": []
}
}
}
// @filename: a.ts
let x = 1;