Skip to content

Commit 7e974fa

Browse files
committed
Modify tests
1 parent 33b5125 commit 7e974fa

File tree

1 file changed

+34
-48
lines changed

1 file changed

+34
-48
lines changed
Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,71 @@
11
// @strictNullChecks: true
22

33
type T = { a: number, b: string };
4-
type TU = { a: number | undefined, b: string | undefined };
54
type TP = { a?: number, b?: string };
65
type TR = { readonly a: number, readonly b: string };
76
type TPR = { readonly a?: number, readonly b?: string };
87

9-
// Validate they all have the same keys
108
var v00: "a" | "b";
119
var v00: keyof T;
12-
var v00: keyof TU;
1310
var v00: keyof TP;
1411
var v00: keyof TR;
1512
var v00: keyof TPR;
1613

17-
// Validate that non-isomorphic mapped types strip modifiers
1814
var v01: T;
19-
var v01: Pick<TR, keyof T>;
20-
var v01: Pick<Readonly<T>, keyof T>;
15+
var v01: { [P in keyof T]: T[P] };
16+
var v01: Pick<T, keyof T>;
17+
var v01: Pick<Pick<T, keyof T>, keyof T>;
2118

22-
// Validate that non-isomorphic mapped types strip modifiers
23-
var v02: TU;
19+
var v02: TP;
20+
var v02: { [P in keyof T]?: T[P] };
21+
var v02: Partial<T>;
2422
var v02: Pick<TP, keyof T>;
25-
var v02: Pick<TPR, keyof T>;
26-
var v02: Pick<Partial<T>, keyof T>;
27-
var v02: Pick<Partial<Readonly<T>>, keyof T>;
2823

29-
// Validate that isomorphic mapped types preserve optional modifier
30-
var v03: TP;
31-
var v03: Partial<T>;
24+
var v03: TR;
25+
var v03: { readonly [P in keyof T]: T[P] };
26+
var v03: Readonly<T>;
27+
var v03: Pick<TR, keyof T>;
3228

33-
// Validate that isomorphic mapped types preserve readonly modifier
34-
var v04: TR;
35-
var v04: Readonly<T>;
36-
37-
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
38-
var v05: TPR;
39-
var v05: Partial<TR>;
40-
var v05: Readonly<TP>;
41-
var v05: Partial<Readonly<T>>;
42-
var v05: Readonly<Partial<T>>;
29+
var v04: TPR;
30+
var v04: { readonly [P in keyof T]?: T[P] };
31+
var v04: Partial<TR>;
32+
var v04: Readonly<TP>;
33+
var v04: Partial<Readonly<T>>;
34+
var v04: Readonly<Partial<T>>;
35+
var v04: Pick<TPR, keyof T>;
4336

4437
type Boxified<T> = { [P in keyof T]: { x: T[P] } };
4538

4639
type B = { a: { x: number }, b: { x: string } };
47-
type BU = { a: { x: number } | undefined, b: { x: string } | undefined };
4840
type BP = { a?: { x: number }, b?: { x: string } };
4941
type BR = { readonly a: { x: number }, readonly b: { x: string } };
5042
type BPR = { readonly a?: { x: number }, readonly b?: { x: string } };
5143

52-
// Validate they all have the same keys
5344
var b00: "a" | "b";
5445
var b00: keyof B;
55-
var b00: keyof BU;
5646
var b00: keyof BP;
5747
var b00: keyof BR;
5848
var b00: keyof BPR;
5949

60-
// Validate that non-isomorphic mapped types strip modifiers
6150
var b01: B;
62-
var b01: Pick<BR, keyof B>;
63-
var b01: Pick<Readonly<BR>, keyof B>;
51+
var b01: { [P in keyof B]: B[P] };
52+
var b01: Pick<B, keyof B>;
53+
var b01: Pick<Pick<B, keyof B>, keyof B>;
6454

65-
// Validate that non-isomorphic mapped types strip modifiers
66-
var b02: BU;
55+
var b02: BP;
56+
var b02: { [P in keyof B]?: B[P] };
57+
var b02: Partial<B>;
6758
var b02: Pick<BP, keyof B>;
68-
var b02: Pick<BPR, keyof B>;
69-
var b02: Pick<Partial<B>, keyof B>;
70-
var b02: Pick<Partial<Readonly<B>>, keyof B>;
71-
72-
// Validate that isomorphic mapped types preserve optional modifier
73-
var b03: BP;
74-
var b03: Partial<B>;
7559

76-
// Validate that isomorphic mapped types preserve readonly modifier
77-
var b04: BR;
78-
var b04: Readonly<B>;
60+
var b03: BR;
61+
var b03: { readonly [P in keyof B]: B[P] };
62+
var b03: Readonly<B>;
63+
var b03: Pick<BR, keyof B>;
7964

80-
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
81-
var b05: BPR;
82-
var b05: Partial<BR>;
83-
var b05: Readonly<BP>;
84-
var b05: Partial<Readonly<B>>;
85-
var b05: Readonly<Partial<B>>;
65+
var b04: BPR;
66+
var b04: { readonly [P in keyof B]?: B[P] };
67+
var b04: Partial<BR>;
68+
var b04: Readonly<BP>;
69+
var b04: Partial<Readonly<B>>;
70+
var b04: Readonly<Partial<B>>;
71+
var b04: Pick<BPR, keyof B>;

0 commit comments

Comments
 (0)