Skip to content

Commit b19a949

Browse files
committed
Support path that specified index
1 parent c67d1a4 commit b19a949

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/services/codefixes/importFixes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ namespace ts.codefix {
443443
return undefined;
444444
}
445445

446+
const relativeNameWithIndex = removeFileExtension(relativeName);
446447
relativeName = removeExtensionAndIndexPostFix(relativeName);
447448

448449
if (options.paths) {
@@ -462,7 +463,7 @@ namespace ts.codefix {
462463
return key.replace("\*", matchedStar);
463464
}
464465
}
465-
else if (pattern === relativeName) {
466+
else if (pattern === relativeName || pattern === relativeNameWithIndex) {
466467
return key;
467468
}
468469
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
//// [|foo/*0*/();|]
4+
5+
// @Filename: folder_b/index.ts
6+
//// export function foo() {};
7+
8+
// @Filename: tsconfig.path.json
9+
//// {
10+
//// "compilerOptions": {
11+
//// "baseUrl": ".",
12+
//// "paths": {
13+
//// "b": [ "folder_b/index" ]
14+
//// }
15+
//// }
16+
//// }
17+
18+
// @Filename: tsconfig.json
19+
//// {
20+
//// "extends": "./tsconfig.path",
21+
//// "compilerOptions": { }
22+
//// }
23+
24+
verify.importFixAtPosition([
25+
`import { foo } from "b";
26+
27+
foo();`
28+
]);

0 commit comments

Comments
 (0)