Avoid using old node in import fix to use namespace import (#25729)

This commit is contained in:
Andy 2018-07-17 13:34:56 -07:00 committed by GitHub
parent a87ed5335b
commit 89f2af17f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -482,7 +482,7 @@ namespace ts.codefix {
}
function addNamespaceQualifier(changes: textChanges.ChangeTracker, sourceFile: SourceFile, { namespacePrefix, symbolToken }: FixUseNamespaceImport): void {
changes.replaceNode(sourceFile, symbolToken, createPropertyAccess(createIdentifier(namespacePrefix), symbolToken));
changes.replaceNode(sourceFile, symbolToken, createPropertyAccess(createIdentifier(namespacePrefix), createIdentifier(symbolToken.text)));
}
interface ImportsCollection {

View file

@ -1,7 +1,8 @@
/// <reference path="fourslash.ts" />
//// [|import * as ns from "./module";
//// f1/*0*/();|]
////import * as ns from "./module";
////// Comment
////f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
@ -9,8 +10,10 @@
verify.importFixAtPosition([
`import * as ns from "./module";
// Comment
ns.f1();`,
`import * as ns from "./module";
import { f1 } from "./module";
// Comment
f1();`,
]);