Skip to content

Commit a849a0f

Browse files
committed
Fixes microsoft#31629 and removes duplicate comments on refactors
1 parent ef83109 commit a849a0f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/services/refactors/extractType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ namespace ts.refactor {
160160
selection
161161
);
162162
changes.insertNodeBefore(file, firstStatement, ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true);
163-
changes.replaceNode(file, selection, createTypeReferenceNode(name, typeParameters.map(id => createTypeReferenceNode(id.name, /* typeArguments */ undefined))));
163+
changes.replaceNode(file, selection, createTypeReferenceNode(name, typeParameters.map(id => createTypeReferenceNode(id.name, /* typeArguments */ undefined))), { trailingTriviaOption: textChanges.TrailingTriviaOption.Include });
164+
164165
}
165166

166167
function doInterfaceChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, info: InterfaceInfo) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path='fourslash.ts' />
2+
/// Doesn't duplicate comments - #31629
3+
4+
//// type a = /*a*/{ x: string } /* foo */ | string /* bar */ /*b*/;
5+
6+
goTo.select("a", "b");
7+
edit.applyRefactor({
8+
refactorName: "Extract type",
9+
actionName: "Extract to type alias",
10+
actionDescription: "Extract to type alias",
11+
newContent: `type /*RENAME*/NewType = {
12+
x: string;
13+
} /* foo */ | string /* bar */;
14+
15+
type a = NewType;`,
16+
});

0 commit comments

Comments
 (0)