Skip to content

Commit 9cfa6e2

Browse files
authored
fix(48405): emit dummy members from a mapped type (microsoft#48481)
1 parent fd601dd commit 9cfa6e2

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

Diff for: src/compiler/emitter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,7 @@ namespace ts {
23702370
writeLine();
23712371
decreaseIndent();
23722372
}
2373+
emitList(node, node.members, ListFormat.PreserveLines);
23732374
writePunctuation("}");
23742375
}
23752376

Diff for: tests/cases/fourslash/refactorExtractType76.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: a.ts
4+
////type Deep<T> = /*a*/{ [K in keyof T]: Deep<T[K]> }/*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:
12+
`type /*RENAME*/NewType<T> = {
13+
[K in keyof T]: Deep<T[K]>;
14+
};
15+
16+
type Deep<T> = NewType<T>`,
17+
});

Diff for: tests/cases/fourslash/refactorExtractType77.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: a.ts
4+
////type Expand<T> = T extends any
5+
//// ? /*a*/{ [K in keyof T]: Expand<T[K]> }/*b*/
6+
//// : never;
7+
8+
goTo.select("a", "b");
9+
edit.applyRefactor({
10+
refactorName: "Extract type",
11+
actionName: "Extract to type alias",
12+
actionDescription: "Extract to type alias",
13+
newContent:
14+
`type /*RENAME*/NewType<T> = {
15+
[K in keyof T]: Expand<T[K]>;
16+
};
17+
18+
type Expand<T> = T extends any
19+
? NewType<T>
20+
: never;`,
21+
});

0 commit comments

Comments
 (0)