Skip to content

Commit c23abc8

Browse files
authored
fix(45192): show implement interface QF for re-exported types (microsoft#45245)
1 parent bfd5b2f commit c23abc8

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/services/codefixes/importFixes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ namespace ts.codefix {
211211
}
212212

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: node_modules/test-module/index.d.ts
4+
////declare namespace e {
5+
//// interface Foo {}
6+
////}
7+
////export = e;
8+
9+
// @Filename: a.ts
10+
////import { Foo } from "test-module";
11+
////export interface A {
12+
//// foo(): Foo;
13+
////}
14+
15+
// @Filename: b.ts
16+
////import { A } from "./a";
17+
////export class B implements A {}
18+
19+
goTo.file("b.ts");
20+
verify.codeFix({
21+
description: "Implement interface 'A'",
22+
newFileContent:
23+
`import { Foo } from "test-module";
24+
import { A } from "./a";
25+
export class B implements A {
26+
foo(): Foo {
27+
throw new Error("Method not implemented.");
28+
}
29+
}`
30+
});

0 commit comments

Comments
 (0)