mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
moduleSpecifiers: Allow "*" as a path mapping (#25881)
This commit is contained in:
parent
2146a91df3
commit
30c41492d9
@ -218,10 +218,7 @@ namespace ts.moduleSpecifiers {
|
||||
for (const patternText of paths[key]) {
|
||||
const pattern = removeFileExtension(normalizePath(patternText));
|
||||
const indexOfStar = pattern.indexOf("*");
|
||||
if (indexOfStar === 0 && pattern.length === 1) {
|
||||
continue;
|
||||
}
|
||||
else if (indexOfStar !== -1) {
|
||||
if (indexOfStar !== -1) {
|
||||
const prefix = pattern.substr(0, indexOfStar);
|
||||
const suffix = pattern.substr(indexOfStar + 1);
|
||||
if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
|
||||
|
||||
24
tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts
Normal file
24
tests/cases/fourslash/importNameCodeFix_fromPathMapping.ts
Normal file
@ -0,0 +1,24 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////export const foo = 0;
|
||||
|
||||
// @Filename: /b.ts
|
||||
////foo;
|
||||
|
||||
// @Filename: /tsconfig.json
|
||||
////{
|
||||
//// "compilerOptions": {
|
||||
//// "baseUrl": ".",
|
||||
//// "paths": {
|
||||
//// "@root/*": ["*"],
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
|
||||
goTo.file("/b.ts");
|
||||
verify.importFixAtPosition([
|
||||
`import { foo } from "@root/a";
|
||||
|
||||
foo;`,
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user