mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix auto import path mapping when first pattern fails (#54868)
This commit is contained in:
parent
88d59e40e4
commit
f4d372aef4
@ -775,7 +775,9 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike<rea
|
||||
validateEnding({ ending, value })
|
||||
) {
|
||||
const matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
||||
return pathIsRelative(matchedStar) ? undefined : key.replace("*", matchedStar);
|
||||
if (!pathIsRelative(matchedStar)) {
|
||||
return key.replace("*", matchedStar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
tests/cases/fourslash/autoImportPaths.ts
Normal file
25
tests/cases/fourslash/autoImportPaths.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: /package1/jsconfig.json
|
||||
//// {
|
||||
//// "compilerOptions": {
|
||||
//// checkJs: true,
|
||||
//// "paths": {
|
||||
//// "package1/*": ["./*"],
|
||||
//// "package2/*": ["../package2/*"]
|
||||
//// },
|
||||
//// "baseUrl": "."
|
||||
//// },
|
||||
//// "include": [
|
||||
//// ".",
|
||||
//// "../package2"
|
||||
//// ]
|
||||
//// }
|
||||
|
||||
// @Filename: /package1/file1.js
|
||||
//// bar/**/
|
||||
|
||||
// @Filename: /package2/file1.js
|
||||
//// export const bar = 0;
|
||||
|
||||
verify.importFixModuleSpecifiers("", ["package2/file1"], { importModuleSpecifierPreference: "shortest" });
|
||||
Loading…
x
Reference in New Issue
Block a user