Skip to content

Commit

Permalink
fix(48405): emit dummy members from a mapped type (#48481)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Mar 31, 2022
1 parent fd601dd commit 9cfa6e2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2370,6 +2370,7 @@ namespace ts {
writeLine();
decreaseIndent();
}
emitList(node, node.members, ListFormat.PreserveLines);
writePunctuation("}");
}

Expand Down
17 changes: 17 additions & 0 deletions tests/cases/fourslash/refactorExtractType76.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference path='fourslash.ts' />

// @Filename: a.ts
////type Deep<T> = /*a*/{ [K in keyof T]: Deep<T[K]> }/*b*/

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent:
`type /*RENAME*/NewType<T> = {
[K in keyof T]: Deep<T[K]>;
};
type Deep<T> = NewType<T>`,
});
21 changes: 21 additions & 0 deletions tests/cases/fourslash/refactorExtractType77.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference path='fourslash.ts' />

// @Filename: a.ts
////type Expand<T> = T extends any
//// ? /*a*/{ [K in keyof T]: Expand<T[K]> }/*b*/
//// : never;

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent:
`type /*RENAME*/NewType<T> = {
[K in keyof T]: Expand<T[K]>;
};
type Expand<T> = T extends any
? NewType<T>
: never;`,
});

0 comments on commit 9cfa6e2

Please sign in to comment.