Skip to content

Commit 89f2af1

Browse files
author
Andy
authored
Avoid using old node in import fix to use namespace import (#25729)
1 parent a87ed53 commit 89f2af1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/services/codefixes/importFixes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ namespace ts.codefix {
482482
}
483483

484484
function addNamespaceQualifier(changes: textChanges.ChangeTracker, sourceFile: SourceFile, { namespacePrefix, symbolToken }: FixUseNamespaceImport): void {
485-
changes.replaceNode(sourceFile, symbolToken, createPropertyAccess(createIdentifier(namespacePrefix), symbolToken));
485+
changes.replaceNode(sourceFile, symbolToken, createPropertyAccess(createIdentifier(namespacePrefix), createIdentifier(symbolToken.text)));
486486
}
487487

488488
interface ImportsCollection {
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/// <reference path="fourslash.ts" />
22

3-
//// [|import * as ns from "./module";
4-
//// f1/*0*/();|]
3+
////import * as ns from "./module";
4+
////// Comment
5+
////f1/*0*/();
56

67
// @Filename: module.ts
78
//// export function f1() {}
89
//// export var v1 = 5;
910

1011
verify.importFixAtPosition([
1112
`import * as ns from "./module";
13+
// Comment
1214
ns.f1();`,
1315
`import * as ns from "./module";
1416
import { f1 } from "./module";
17+
// Comment
1518
f1();`,
1619
]);

0 commit comments

Comments
 (0)