mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Ensure that the comma is removed when all named imports are removed via moveToFile - fixes #31195
This commit is contained in:
parent
b377e99958
commit
c337f046fb
@ -2430,7 +2430,7 @@ namespace FourSlash {
|
||||
const oldText = this.tryGetFileContent(change.fileName);
|
||||
ts.Debug.assert(!!change.isNewFile === (oldText === undefined));
|
||||
const newContent = change.isNewFile ? ts.first(change.textChanges).newText : ts.textChanges.applyChanges(oldText!, change.textChanges);
|
||||
assert.equal(newContent, expectedNewContent);
|
||||
assert.equal(newContent, expectedNewContent, `String mis-matched in file ${change.fileName}`);
|
||||
}
|
||||
for (const newFileName in newFileContent) {
|
||||
ts.Debug.assert(changes.some(c => c.fileName === newFileName), "No change in file", () => newFileName);
|
||||
|
||||
@ -350,7 +350,11 @@ namespace ts.refactor {
|
||||
}
|
||||
if (namedBindings) {
|
||||
if (namedBindingsUnused) {
|
||||
changes.delete(sourceFile, namedBindings);
|
||||
changes.replaceNode(
|
||||
sourceFile,
|
||||
importDecl.importClause,
|
||||
updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)
|
||||
);
|
||||
}
|
||||
else if (namedBindings.kind === SyntaxKind.NamedImports) {
|
||||
for (const element of namedBindings.elements) {
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /has-exports.ts
|
||||
////
|
||||
//// export interface Exported { }
|
||||
//// const defaultExport = ""
|
||||
//// export default defaultExport
|
||||
|
||||
// @Filename: /31195.ts
|
||||
////
|
||||
////import defaultExport, { Exported } from "./has-exports"
|
||||
////console.log(defaultExport)
|
||||
////[|export const bar = (logger: Exported) => 0;|]
|
||||
|
||||
verify.moveToNewFile({
|
||||
newFileContents: {
|
||||
"/31195.ts": `
|
||||
import defaultExport from "./has-exports"
|
||||
console.log(defaultExport)
|
||||
`,
|
||||
|
||||
"/bar.ts":
|
||||
`import { Exported } from "./has-exports";
|
||||
export const bar = (logger: Exported) => 0;
|
||||
`,
|
||||
}
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user