mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
added validation of paths option
This commit is contained in:
parent
41c1a5b497
commit
e7a4dd4cf5
@ -2292,7 +2292,14 @@
|
||||
"category": "Error",
|
||||
"code": 5062
|
||||
},
|
||||
|
||||
"Substututions for patterns '{0}' should be an array.": {
|
||||
"category": "Error",
|
||||
"code": 5063
|
||||
},
|
||||
"Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 5064
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
|
||||
@ -1985,11 +1985,22 @@ namespace ts {
|
||||
if (!hasZeroOrOneAsteriskCharacter(key)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key));
|
||||
}
|
||||
for (const subst of options.paths[key]) {
|
||||
if (!hasZeroOrOneAsteriskCharacter(subst)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key));
|
||||
if (isArray(options.paths[key])) {
|
||||
for (const subst of options.paths[key]) {
|
||||
const typeOfSubst = typeof subst;
|
||||
if (typeOfSubst === "string") {
|
||||
if (!hasZeroOrOneAsteriskCharacter(subst)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key));
|
||||
}
|
||||
}
|
||||
else {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Substututions_for_patterns_0_should_be_an_array, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
tests/baselines/reference/pathsValidation1.errors.txt
Normal file
6
tests/baselines/reference/pathsValidation1.errors.txt
Normal file
@ -0,0 +1,6 @@
|
||||
error TS5063: Substututions for patterns '*' should be an array.
|
||||
|
||||
|
||||
!!! error TS5063: Substututions for patterns '*' should be an array.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
let x = 1;
|
||||
5
tests/baselines/reference/pathsValidation1.js
Normal file
5
tests/baselines/reference/pathsValidation1.js
Normal file
@ -0,0 +1,5 @@
|
||||
//// [a.ts]
|
||||
let x = 1;
|
||||
|
||||
//// [a.js]
|
||||
var x = 1;
|
||||
6
tests/baselines/reference/pathsValidation2.errors.txt
Normal file
6
tests/baselines/reference/pathsValidation2.errors.txt
Normal file
@ -0,0 +1,6 @@
|
||||
error TS5064: Substitution '1' for pattern '*' has incorrect type, expected 'string', got 'number'.
|
||||
|
||||
|
||||
!!! error TS5064: Substitution '1' for pattern '*' has incorrect type, expected 'string', got 'number'.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
let x = 1;
|
||||
5
tests/baselines/reference/pathsValidation2.js
Normal file
5
tests/baselines/reference/pathsValidation2.js
Normal file
@ -0,0 +1,5 @@
|
||||
//// [a.ts]
|
||||
let x = 1;
|
||||
|
||||
//// [a.js]
|
||||
var x = 1;
|
||||
11
tests/cases/compiler/pathsValidation1.ts
Normal file
11
tests/cases/compiler/pathsValidation1.ts
Normal file
@ -0,0 +1,11 @@
|
||||
// @filename: tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": "*"
|
||||
}
|
||||
}
|
||||
}
|
||||
// @filename: a.ts
|
||||
let x = 1;
|
||||
11
tests/cases/compiler/pathsValidation2.ts
Normal file
11
tests/cases/compiler/pathsValidation2.ts
Normal file
@ -0,0 +1,11 @@
|
||||
// @filename: tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": [1]
|
||||
}
|
||||
}
|
||||
}
|
||||
// @filename: a.ts
|
||||
let x = 1;
|
||||
Loading…
x
Reference in New Issue
Block a user