Support path that specified index

This commit is contained in:
Zhengbo Li 2017-01-04 13:35:42 -08:00
parent c67d1a4445
commit b19a949ce4
2 changed files with 30 additions and 1 deletions

View File

@ -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;
}
}

View 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();`
]);