Skip to content

Commit 5028a44

Browse files
committed
Accept new baselines
1 parent ca3f797 commit 5028a44

File tree

5 files changed

+346
-18
lines changed

5 files changed

+346
-18
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(34,20): error TS2313: Type parameter 'P' has a circular constraint.
2+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(35,20): error TS2322: Type 'Date' is not assignable to type 'string | number'.
3+
Type 'Date' is not assignable to type 'number'.
4+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(36,19): error TS2344: Type 'Date' does not satisfy the constraint 'string | number'.
5+
Type 'Date' is not assignable to type 'number'.
6+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(39,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
7+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(40,24): error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
8+
Type '"foo"' is not assignable to type '"name" | "width" | "height" | "visible"'.
9+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(42,24): error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
10+
Type '"x"' is not assignable to type '"name" | "width" | "height" | "visible"'.
11+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(44,24): error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
12+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(47,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
13+
Type 'T' is not assignable to type '"visible"'.
14+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(51,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
15+
Type 'string | number' is not assignable to type '"name" | "width" | "height" | "visible"'.
16+
Type 'string' is not assignable to type '"name" | "width" | "height" | "visible"'.
17+
Type 'T' is not assignable to type '"visible"'.
18+
Type 'string | number' is not assignable to type '"visible"'.
19+
Type 'string' is not assignable to type '"visible"'.
20+
21+
22+
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (9 errors) ====
23+
24+
type Partial<T> = {
25+
[P in keyof T]?: T[P];
26+
};
27+
28+
type Readonly<T> = {
29+
readonly [P in keyof T]: T[P];
30+
};
31+
32+
type Pick<T, K extends keyof T> = {
33+
[P in K]: T[P];
34+
}
35+
36+
type Record<K extends string | number, T> = {
37+
[_ in K]: T;
38+
}
39+
40+
interface Shape {
41+
name: string;
42+
width: number;
43+
height: number;
44+
visible: boolean;
45+
}
46+
47+
interface Named {
48+
name: string;
49+
}
50+
51+
interface Point {
52+
x: number;
53+
y: number;
54+
}
55+
56+
type T00 = { [P in P]: string }; // Error
57+
~
58+
!!! error TS2313: Type parameter 'P' has a circular constraint.
59+
type T01 = { [P in Date]: number }; // Error
60+
~~~~
61+
!!! error TS2322: Type 'Date' is not assignable to type 'string | number'.
62+
!!! error TS2322: Type 'Date' is not assignable to type 'number'.
63+
type T02 = Record<Date, number>; // Error
64+
~~~~
65+
!!! error TS2344: Type 'Date' does not satisfy the constraint 'string | number'.
66+
!!! error TS2344: Type 'Date' is not assignable to type 'number'.
67+
68+
type T10 = Pick<Shape, "name">;
69+
type T11 = Pick<Shape, "foo">; // Error
70+
~~~~~
71+
!!! error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
72+
type T12 = Pick<Shape, "name" | "foo">; // Error
73+
~~~~~~~~~~~~~~
74+
!!! error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
75+
!!! error TS2344: Type '"foo"' is not assignable to type '"name" | "width" | "height" | "visible"'.
76+
type T13 = Pick<Shape, keyof Named>;
77+
type T14 = Pick<Shape, keyof Point>; // Error
78+
~~~~~~~~~~~
79+
!!! error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
80+
!!! error TS2344: Type '"x"' is not assignable to type '"name" | "width" | "height" | "visible"'.
81+
type T15 = Pick<Shape, never>;
82+
type T16 = Pick<Shape, undefined>;
83+
~~~~~~~~~
84+
!!! error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
85+
86+
function f1<T>(x: T) {
87+
let y: Pick<Shape, T>; // Error
88+
~
89+
!!! error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
90+
!!! error TS2344: Type 'T' is not assignable to type '"visible"'.
91+
}
92+
93+
function f2<T extends string | number>(x: T) {
94+
let y: Pick<Shape, T>; // Error
95+
~
96+
!!! error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
97+
!!! error TS2344: Type 'string | number' is not assignable to type '"name" | "width" | "height" | "visible"'.
98+
!!! error TS2344: Type 'string' is not assignable to type '"name" | "width" | "height" | "visible"'.
99+
!!! error TS2344: Type 'T' is not assignable to type '"visible"'.
100+
!!! error TS2344: Type 'string | number' is not assignable to type '"visible"'.
101+
!!! error TS2344: Type 'string' is not assignable to type '"visible"'.
102+
}
103+
104+
function f3<T extends keyof Shape>(x: T) {
105+
let y: Pick<Shape, T>;
106+
}
107+
108+
function f4<T extends keyof Named>(x: T) {
109+
let y: Pick<Shape, T>;
110+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//// [mappedTypeErrors.ts]
2+
3+
type Partial<T> = {
4+
[P in keyof T]?: T[P];
5+
};
6+
7+
type Readonly<T> = {
8+
readonly [P in keyof T]: T[P];
9+
};
10+
11+
type Pick<T, K extends keyof T> = {
12+
[P in K]: T[P];
13+
}
14+
15+
type Record<K extends string | number, T> = {
16+
[_ in K]: T;
17+
}
18+
19+
interface Shape {
20+
name: string;
21+
width: number;
22+
height: number;
23+
visible: boolean;
24+
}
25+
26+
interface Named {
27+
name: string;
28+
}
29+
30+
interface Point {
31+
x: number;
32+
y: number;
33+
}
34+
35+
type T00 = { [P in P]: string }; // Error
36+
type T01 = { [P in Date]: number }; // Error
37+
type T02 = Record<Date, number>; // Error
38+
39+
type T10 = Pick<Shape, "name">;
40+
type T11 = Pick<Shape, "foo">; // Error
41+
type T12 = Pick<Shape, "name" | "foo">; // Error
42+
type T13 = Pick<Shape, keyof Named>;
43+
type T14 = Pick<Shape, keyof Point>; // Error
44+
type T15 = Pick<Shape, never>;
45+
type T16 = Pick<Shape, undefined>;
46+
47+
function f1<T>(x: T) {
48+
let y: Pick<Shape, T>; // Error
49+
}
50+
51+
function f2<T extends string | number>(x: T) {
52+
let y: Pick<Shape, T>; // Error
53+
}
54+
55+
function f3<T extends keyof Shape>(x: T) {
56+
let y: Pick<Shape, T>;
57+
}
58+
59+
function f4<T extends keyof Named>(x: T) {
60+
let y: Pick<Shape, T>;
61+
}
62+
63+
//// [mappedTypeErrors.js]
64+
function f1(x) {
65+
var y; // Error
66+
}
67+
function f2(x) {
68+
var y; // Error
69+
}
70+
function f3(x) {
71+
var y;
72+
}
73+
function f4(x) {
74+
var y;
75+
}
76+
77+
78+
//// [mappedTypeErrors.d.ts]
79+
declare type Partial<T> = {
80+
[P in keyof T]?: T[P];
81+
};
82+
declare type Readonly<T> = {
83+
readonly [P in keyof T]: T[P];
84+
};
85+
declare type Pick<T, K extends keyof T> = {
86+
[P in K]: T[P];
87+
};
88+
declare type Record<K extends string | number, T> = {
89+
[_ in K]: T;
90+
};
91+
interface Shape {
92+
name: string;
93+
width: number;
94+
height: number;
95+
visible: boolean;
96+
}
97+
interface Named {
98+
name: string;
99+
}
100+
interface Point {
101+
x: number;
102+
y: number;
103+
}
104+
declare type T00 = {
105+
[P in P]: string;
106+
};
107+
declare type T01 = {
108+
[P in Date]: number;
109+
};
110+
declare type T02 = Record<Date, number>;
111+
declare type T10 = Pick<Shape, "name">;
112+
declare type T11 = Pick<Shape, "foo">;
113+
declare type T12 = Pick<Shape, "name" | "foo">;
114+
declare type T13 = Pick<Shape, keyof Named>;
115+
declare type T14 = Pick<Shape, keyof Point>;
116+
declare type T15 = Pick<Shape, never>;
117+
declare type T16 = Pick<Shape, undefined>;
118+
declare function f1<T>(x: T): void;
119+
declare function f2<T extends string | number>(x: T): void;
120+
declare function f3<T extends keyof Shape>(x: T): void;
121+
declare function f4<T extends keyof Named>(x: T): void;

tests/baselines/reference/mappedTypes1.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ type T36 = { [P in keyof void]: void };
2525
type T37 = { [P in keyof symbol]: void };
2626
type T38 = { [P in keyof never]: void };
2727

28+
type T40 = { [P in string]: void };
29+
type T41 = { [P in number]: void };
30+
type T42 = { [P in string | number]: void };
31+
type T43 = { [P in "a" | "b" | 0 | 1]: void };
32+
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
33+
type T45 = { [P in "a" | "b" | "0" | "1" | 0 | 1]: void };
34+
type T46 = { [P in number | "a" | "b" | 0 | 1]: void };
35+
type T47 = { [P in string | number | "a" | "b" | 0 | 1]: void };
36+
2837
declare function f1<T1>(): { [P in keyof T1]: void };
2938
declare function f2<T1 extends string>(): { [P in keyof T1]: void };
3039
declare function f3<T1 extends number>(): { [P in keyof T1]: void };
@@ -102,6 +111,30 @@ declare type T37 = {
102111
declare type T38 = {
103112
[P in keyof never]: void;
104113
};
114+
declare type T40 = {
115+
[P in string]: void;
116+
};
117+
declare type T41 = {
118+
[P in number]: void;
119+
};
120+
declare type T42 = {
121+
[P in string | number]: void;
122+
};
123+
declare type T43 = {
124+
[P in "a" | "b" | 0 | 1]: void;
125+
};
126+
declare type T44 = {
127+
[P in "a" | "b" | "0" | "1"]: void;
128+
};
129+
declare type T45 = {
130+
[P in "a" | "b" | "0" | "1" | 0 | 1]: void;
131+
};
132+
declare type T46 = {
133+
[P in number | "a" | "b" | 0 | 1]: void;
134+
};
135+
declare type T47 = {
136+
[P in string | number | "a" | "b" | 0 | 1]: void;
137+
};
105138
declare function f1<T1>(): {
106139
[P in keyof T1]: void;
107140
};

tests/baselines/reference/mappedTypes1.symbols

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,33 +106,65 @@ type T38 = { [P in keyof never]: void };
106106
>T38 : Symbol(T38, Decl(mappedTypes1.ts, 23, 41))
107107
>P : Symbol(P, Decl(mappedTypes1.ts, 24, 14))
108108

109+
type T40 = { [P in string]: void };
110+
>T40 : Symbol(T40, Decl(mappedTypes1.ts, 24, 40))
111+
>P : Symbol(P, Decl(mappedTypes1.ts, 26, 14))
112+
113+
type T41 = { [P in number]: void };
114+
>T41 : Symbol(T41, Decl(mappedTypes1.ts, 26, 35))
115+
>P : Symbol(P, Decl(mappedTypes1.ts, 27, 14))
116+
117+
type T42 = { [P in string | number]: void };
118+
>T42 : Symbol(T42, Decl(mappedTypes1.ts, 27, 35))
119+
>P : Symbol(P, Decl(mappedTypes1.ts, 28, 14))
120+
121+
type T43 = { [P in "a" | "b" | 0 | 1]: void };
122+
>T43 : Symbol(T43, Decl(mappedTypes1.ts, 28, 44))
123+
>P : Symbol(P, Decl(mappedTypes1.ts, 29, 14))
124+
125+
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
126+
>T44 : Symbol(T44, Decl(mappedTypes1.ts, 29, 46))
127+
>P : Symbol(P, Decl(mappedTypes1.ts, 30, 14))
128+
129+
type T45 = { [P in "a" | "b" | "0" | "1" | 0 | 1]: void };
130+
>T45 : Symbol(T45, Decl(mappedTypes1.ts, 30, 50))
131+
>P : Symbol(P, Decl(mappedTypes1.ts, 31, 14))
132+
133+
type T46 = { [P in number | "a" | "b" | 0 | 1]: void };
134+
>T46 : Symbol(T46, Decl(mappedTypes1.ts, 31, 58))
135+
>P : Symbol(P, Decl(mappedTypes1.ts, 32, 14))
136+
137+
type T47 = { [P in string | number | "a" | "b" | 0 | 1]: void };
138+
>T47 : Symbol(T47, Decl(mappedTypes1.ts, 32, 55))
139+
>P : Symbol(P, Decl(mappedTypes1.ts, 33, 14))
140+
109141
declare function f1<T1>(): { [P in keyof T1]: void };
110-
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 24, 40))
111-
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 26, 20))
112-
>P : Symbol(P, Decl(mappedTypes1.ts, 26, 30))
113-
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 26, 20))
142+
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 33, 64))
143+
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 35, 20))
144+
>P : Symbol(P, Decl(mappedTypes1.ts, 35, 30))
145+
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 35, 20))
114146

115147
declare function f2<T1 extends string>(): { [P in keyof T1]: void };
116-
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 26, 53))
117-
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 27, 20))
118-
>P : Symbol(P, Decl(mappedTypes1.ts, 27, 45))
119-
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 27, 20))
148+
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 35, 53))
149+
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 36, 20))
150+
>P : Symbol(P, Decl(mappedTypes1.ts, 36, 45))
151+
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 36, 20))
120152

121153
declare function f3<T1 extends number>(): { [P in keyof T1]: void };
122-
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 27, 68))
123-
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 28, 20))
124-
>P : Symbol(P, Decl(mappedTypes1.ts, 28, 45))
125-
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 28, 20))
154+
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 36, 68))
155+
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 37, 20))
156+
>P : Symbol(P, Decl(mappedTypes1.ts, 37, 45))
157+
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 37, 20))
126158

127159
let x1 = f1();
128-
>x1 : Symbol(x1, Decl(mappedTypes1.ts, 30, 3))
129-
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 24, 40))
160+
>x1 : Symbol(x1, Decl(mappedTypes1.ts, 39, 3))
161+
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 33, 64))
130162

131163
let x2 = f2();
132-
>x2 : Symbol(x2, Decl(mappedTypes1.ts, 31, 3))
133-
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 26, 53))
164+
>x2 : Symbol(x2, Decl(mappedTypes1.ts, 40, 3))
165+
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 35, 53))
134166

135167
let x3 = f3();
136-
>x3 : Symbol(x3, Decl(mappedTypes1.ts, 32, 3))
137-
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 27, 68))
168+
>x3 : Symbol(x3, Decl(mappedTypes1.ts, 41, 3))
169+
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 36, 68))
138170

0 commit comments

Comments
 (0)