Skip to content

Commit 83c257d

Browse files
committed
Support import completion for merged declaration exports
1 parent 70ad5a3 commit 83c257d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/services/codefixes/importFixes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ namespace ts.codefix {
111111
}
112112

113113
for (const exported of checker.getExportsOfModule(moduleSymbol)) {
114-
if ((exported.escapedName === InternalSymbolName.Default || exported.name === symbolName) && skipAlias(exported, checker) === exportedSymbol) {
114+
if ((exported.escapedName === InternalSymbolName.Default || exported.name === symbolName) && exported.declarations.some(decl => skipAlias(decl.symbol, checker) === exportedSymbol)) {
115115
const isDefaultExport = checker.tryGetMemberInModuleExports(InternalSymbolName.Default, moduleSymbol) === exported;
116116
result.push({ moduleSymbol, importKind: isDefaultExport ? ImportKind.Default : ImportKind.Named });
117117
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @module: esnext
4+
5+
// @Filename: /a.ts
6+
////declare module "m" {
7+
//// export default class M {}
8+
////}
9+
10+
// @Filename: /b.ts
11+
////declare module "m" {
12+
//// export default interface M {}
13+
////}
14+
15+
// @Filename: /c.ts
16+
/////**/
17+
18+
goTo.marker("");
19+
verify.completionListContains({ name: "M", source: "m" }, "class M", "", "class", /*spanIndex*/ undefined, /*hasAction*/ true, {
20+
includeCompletionsForModuleExports: true,
21+
sourceDisplay: "m",
22+
});
23+
24+
verify.applyCodeActionFromCompletion("", {
25+
name: "M",
26+
source: "m",
27+
description: `Import 'M' from module "m"`,
28+
newFileContent: `import M from "m";
29+
30+
`,
31+
});

0 commit comments

Comments
 (0)