mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 21:37:41 -06:00
Support path that specified index
This commit is contained in:
parent
c67d1a4445
commit
b19a949ce4
@ -443,6 +443,7 @@ namespace ts.codefix {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const relativeNameWithIndex = removeFileExtension(relativeName);
|
||||
relativeName = removeExtensionAndIndexPostFix(relativeName);
|
||||
|
||||
if (options.paths) {
|
||||
@ -462,7 +463,7 @@ namespace ts.codefix {
|
||||
return key.replace("\*", matchedStar);
|
||||
}
|
||||
}
|
||||
else if (pattern === relativeName) {
|
||||
else if (pattern === relativeName || pattern === relativeNameWithIndex) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
28
tests/cases/fourslash/importNameCodeFixNewImportPaths2.ts
Normal file
28
tests/cases/fourslash/importNameCodeFixNewImportPaths2.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// [|foo/*0*/();|]
|
||||
|
||||
// @Filename: folder_b/index.ts
|
||||
//// export function foo() {};
|
||||
|
||||
// @Filename: tsconfig.path.json
|
||||
//// {
|
||||
//// "compilerOptions": {
|
||||
//// "baseUrl": ".",
|
||||
//// "paths": {
|
||||
//// "b": [ "folder_b/index" ]
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
|
||||
// @Filename: tsconfig.json
|
||||
//// {
|
||||
//// "extends": "./tsconfig.path",
|
||||
//// "compilerOptions": { }
|
||||
//// }
|
||||
|
||||
verify.importFixAtPosition([
|
||||
`import { foo } from "b";
|
||||
|
||||
foo();`
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user