Merge pull request #13424 from zhengbli/13129

Change the module specifier search order
This commit is contained in:
Zhengbo Li 2017-01-12 12:06:28 -08:00 committed by GitHub
commit a36db0ea10
2 changed files with 25 additions and 2 deletions

View file

@ -420,10 +420,10 @@ namespace ts.codefix {
const options = context.program.getCompilerOptions();
return tryGetModuleNameFromAmbientModule() ||
tryGetModuleNameFromBaseUrl() ||
tryGetModuleNameFromRootDirs() ||
tryGetModuleNameFromTypeRoots() ||
tryGetModuleNameAsNodeModule() ||
tryGetModuleNameFromBaseUrl() ||
tryGetModuleNameFromRootDirs() ||
removeFileExtension(getRelativePath(moduleFileName, sourceDirectory));
function tryGetModuleNameFromAmbientModule(): string {

View file

@ -0,0 +1,23 @@
/// <reference path="fourslash.ts" />
// @Filename: a/f1.ts
//// [|foo/*0*/();|]
// @Filename: types/random/index.ts
//// export function foo() {};
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "baseUrl": ".",
//// "typeRoots": [
//// "./types"
//// ]
//// }
//// }
verify.importFixAtPosition([
`import { foo } from "random";
foo();`
]);