Fix the usage of pattern matching in module resolution for check of hasZeroOrOneAsteriskCharacter (#35209)
* Fix the usage of pattern matching for check of hasZeroOrOneAsteriskCharacter Fixes #35171 * Fix error message
This commit is contained in:
parent
17f5469a2c
commit
0e736a7438
|
@ -3241,7 +3241,7 @@
|
|||
"category": "Error",
|
||||
"code": 5061
|
||||
},
|
||||
"Substitution '{0}' in pattern '{1}' in can have at most one '*' character.": {
|
||||
"Substitution '{0}' in pattern '{1}' can have at most one '*' character.": {
|
||||
"category": "Error",
|
||||
"code": 5062
|
||||
},
|
||||
|
|
|
@ -2980,7 +2980,7 @@ namespace ts {
|
|||
const typeOfSubst = typeof subst;
|
||||
if (typeOfSubst === "string") {
|
||||
if (!hasZeroOrOneAsteriskCharacter(subst)) {
|
||||
createDiagnosticForOptionPathKeyValue(key, i, Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
|
||||
createDiagnosticForOptionPathKeyValue(key, i, Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -8285,6 +8285,7 @@ namespace ts {
|
|||
export function matchPatternOrExact(patternStrings: readonly string[], candidate: string): string | Pattern | undefined {
|
||||
const patterns: Pattern[] = [];
|
||||
for (const patternString of patternStrings) {
|
||||
if (!hasZeroOrOneAsteriskCharacter(patternString)) continue;
|
||||
const pattern = tryParsePattern(patternString);
|
||||
if (pattern) {
|
||||
patterns.push(pattern);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
tests/cases/compiler/root/tsconfig.json(8,13): error TS5061: Pattern '*1*' can have at most one '*' character.
|
||||
tests/cases/compiler/root/tsconfig.json(8,22): error TS5062: Substitution '*2*' in pattern '*1*' in can have at most one '*' character.
|
||||
tests/cases/compiler/root/tsconfig.json(8,22): error TS5062: Substitution '*2*' in pattern '*1*' can have at most one '*' character.
|
||||
|
||||
|
||||
==== tests/cases/compiler/root/tsconfig.json (2 errors) ====
|
||||
|
@ -14,7 +14,7 @@ tests/cases/compiler/root/tsconfig.json(8,22): error TS5062: Substitution '*2*'
|
|||
~~~~~
|
||||
!!! error TS5061: Pattern '*1*' can have at most one '*' character.
|
||||
~~~~~
|
||||
!!! error TS5062: Substitution '*2*' in pattern '*1*' in can have at most one '*' character.
|
||||
!!! error TS5062: Substitution '*2*' in pattern '*1*' can have at most one '*' character.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
tests/cases/compiler/root/tsconfig.json(8,13): error TS5061: Pattern '*1*' can have at most one '*' character.
|
||||
tests/cases/compiler/root/tsconfig.json(8,22): error TS5062: Substitution '*2*' in pattern '*1*' in can have at most one '*' character.
|
||||
tests/cases/compiler/root/tsconfig.json(8,22): error TS5062: Substitution '*2*' in pattern '*1*' can have at most one '*' character.
|
||||
|
||||
|
||||
==== tests/cases/compiler/root/tsconfig.json (2 errors) ====
|
||||
|
@ -14,7 +14,7 @@ tests/cases/compiler/root/tsconfig.json(8,22): error TS5062: Substitution '*2*'
|
|||
~~~~~
|
||||
!!! error TS5061: Pattern '*1*' can have at most one '*' character.
|
||||
~~~~~
|
||||
!!! error TS5062: Substitution '*2*' in pattern '*1*' in can have at most one '*' character.
|
||||
!!! error TS5062: Substitution '*2*' in pattern '*1*' can have at most one '*' character.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
26
tests/baselines/reference/pathsValidation4.errors.txt
Normal file
26
tests/baselines/reference/pathsValidation4.errors.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
tests/cases/compiler/tsconfig.json(6,11): error TS5061: Pattern '@interface/**/*' can have at most one '*' character.
|
||||
tests/cases/compiler/tsconfig.json(7,11): error TS5061: Pattern '@service/**/*' can have at most one '*' character.
|
||||
tests/cases/compiler/tsconfig.json(7,29): error TS5062: Substitution './src/service/**/*' in pattern '@service/**/*' can have at most one '*' character.
|
||||
|
||||
|
||||
==== tests/cases/compiler/tsconfig.json (3 errors) ====
|
||||
{
|
||||
"compilerOptions": {
|
||||
"traceResolution": true,
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"@interface/**/*" : ["./src/interface/*"],
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS5061: Pattern '@interface/**/*' can have at most one '*' character.
|
||||
"@service/**/*": ["./src/service/**/*"],
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS5061: Pattern '@service/**/*' can have at most one '*' character.
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS5062: Substitution './src/service/**/*' in pattern '@service/**/*' can have at most one '*' character.
|
||||
"@controller/*": ["controller/*"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/src/main.ts (0 errors) ====
|
||||
import 'someModule';
|
7
tests/baselines/reference/pathsValidation4.js
Normal file
7
tests/baselines/reference/pathsValidation4.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [main.ts]
|
||||
import 'someModule';
|
||||
|
||||
//// [main.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
require("someModule");
|
36
tests/baselines/reference/pathsValidation4.trace.json
Normal file
36
tests/baselines/reference/pathsValidation4.trace.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
[
|
||||
"======== Resolving module 'someModule' from 'tests/cases/compiler/src/main.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
"'baseUrl' option is set to 'tests/cases/compiler/src', using this value to resolve non-relative module name 'someModule'.",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'someModule'.",
|
||||
"'baseUrl' option is set to 'tests/cases/compiler/src', using this value to resolve non-relative module name 'someModule'.",
|
||||
"Resolving module name 'someModule' relative to base url 'tests/cases/compiler/src' - 'tests/cases/compiler/src/someModule'.",
|
||||
"Loading module as file / folder, candidate module location 'tests/cases/compiler/src/someModule', target file type 'TypeScript'.",
|
||||
"File 'tests/cases/compiler/src/someModule.ts' does not exist.",
|
||||
"File 'tests/cases/compiler/src/someModule.tsx' does not exist.",
|
||||
"File 'tests/cases/compiler/src/someModule.d.ts' does not exist.",
|
||||
"Directory 'tests/cases/compiler/src/someModule' does not exist, skipping all lookups in it.",
|
||||
"Loading module 'someModule' from 'node_modules' folder, target file type 'TypeScript'.",
|
||||
"Directory 'tests/cases/compiler/src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'tests/cases/compiler/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'tests/cases/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'tests/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"'baseUrl' option is set to 'tests/cases/compiler/src', using this value to resolve non-relative module name 'someModule'.",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'someModule'.",
|
||||
"'baseUrl' option is set to 'tests/cases/compiler/src', using this value to resolve non-relative module name 'someModule'.",
|
||||
"Resolving module name 'someModule' relative to base url 'tests/cases/compiler/src' - 'tests/cases/compiler/src/someModule'.",
|
||||
"Loading module as file / folder, candidate module location 'tests/cases/compiler/src/someModule', target file type 'JavaScript'.",
|
||||
"File 'tests/cases/compiler/src/someModule.js' does not exist.",
|
||||
"File 'tests/cases/compiler/src/someModule.jsx' does not exist.",
|
||||
"Directory 'tests/cases/compiler/src/someModule' does not exist, skipping all lookups in it.",
|
||||
"Loading module 'someModule' from 'node_modules' folder, target file type 'JavaScript'.",
|
||||
"Directory 'tests/cases/compiler/src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'tests/cases/compiler/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'tests/cases/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'tests/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory 'node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name 'someModule' was not resolved. ========"
|
||||
]
|
16
tests/cases/compiler/pathsValidation4.ts
Normal file
16
tests/cases/compiler/pathsValidation4.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
// @noTypesAndSymbols: true
|
||||
// @filename: tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"traceResolution": true,
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"@interface/**/*" : ["./src/interface/*"],
|
||||
"@service/**/*": ["./src/service/**/*"],
|
||||
"@controller/*": ["controller/*"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: src/main.ts
|
||||
import 'someModule';
|
Loading…
Reference in a new issue