Skip to content

Commit 9cdea10

Browse files
committed
fix(47821): skip nodes with export modifiers
1 parent df673f7 commit 9cdea10

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

src/services/refactors/convertExport.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ namespace ts.refactor {
165165
const checker = program.getTypeChecker();
166166
const exportSymbol = Debug.checkDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol");
167167
FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, ref => {
168+
if (exportName === ref) return;
168169
const importingSourceFile = ref.getSourceFile();
169170
if (wasDefault) {
170171
changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: /foo.ts
4+
////export {};
5+
////declare module "foo" {
6+
//// /*a*/export function foo(): void;/*b*/
7+
////}
8+
9+
// @Filename: /b.ts
10+
////import foo from "foo";
11+
12+
goTo.select("a", "b");
13+
edit.applyRefactor({
14+
refactorName: "Convert export",
15+
actionName: "Convert named export to default export",
16+
actionDescription: "Convert named export to default export",
17+
newContent: {
18+
"/foo.ts":
19+
`export {};
20+
declare module "foo" {
21+
export default function foo(): void;
22+
}`,
23+
"/b.ts":
24+
`import foo from "foo";`
25+
}
26+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////export {};
4+
////declare module "foo" {
5+
//// /*a*/export function func(): void;/*b*/
6+
////}
7+
8+
goTo.select("a", "b");
9+
edit.applyRefactor({
10+
refactorName: "Convert export",
11+
actionName: "Convert named export to default export",
12+
actionDescription: "Convert named export to default export",
13+
newContent:
14+
`export {};
15+
declare module "foo" {
16+
export default function func(): void;
17+
}`
18+
});

0 commit comments

Comments
 (0)