fix(45192): show implement interface QF for re-exported types (#45245)

This commit is contained in:
Oleksandr T
2021-08-03 01:19:19 +03:00
committed by GitHub
parent bfd5b2f7f0
commit c23abc8957
2 changed files with 31 additions and 1 deletions

View File

@@ -211,7 +211,7 @@ namespace ts.codefix {
}
function getImportFixForSymbol(sourceFile: SourceFile, exportInfos: readonly SymbolExportInfo[], moduleSymbol: Symbol, symbolName: string, program: Program, position: number | undefined, preferTypeOnlyImport: boolean, useRequire: boolean, host: LanguageServiceHost, preferences: UserPreferences) {
Debug.assert(exportInfos.some(info => info.moduleSymbol === moduleSymbol), "Some exportInfo should match the specified moduleSymbol");
Debug.assert(exportInfos.some(info => info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol), "Some exportInfo should match the specified moduleSymbol");
return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, program, host, preferences);
}

View File

@@ -0,0 +1,30 @@
/// <reference path='fourslash.ts' />
// @Filename: node_modules/test-module/index.d.ts
////declare namespace e {
//// interface Foo {}
////}
////export = e;
// @Filename: a.ts
////import { Foo } from "test-module";
////export interface A {
//// foo(): Foo;
////}
// @Filename: b.ts
////import { A } from "./a";
////export class B implements A {}
goTo.file("b.ts");
verify.codeFix({
description: "Implement interface 'A'",
newFileContent:
`import { Foo } from "test-module";
import { A } from "./a";
export class B implements A {
foo(): Foo {
throw new Error("Method not implemented.");
}
}`
});