Skip to content

Commit 997c586

Browse files
committed
Accept new baselines
1 parent 04a0f55 commit 997c586

File tree

5 files changed

+342
-297
lines changed

5 files changed

+342
-297
lines changed

tests/baselines/reference/mappedTypeErrors.errors.txt

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,29 @@
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'.
1+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(20,20): error TS2313: Type parameter 'P' has a circular constraint.
2+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(21,20): error TS2322: Type 'Date' is not assignable to type 'string | number'.
33
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'.
4+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(22,19): error TS2344: Type 'Date' does not satisfy the constraint 'string | number'.
55
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"'.
6+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(25,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
7+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(26,24): error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
88
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"'.
9+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(28,24): error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
1010
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"'.
11+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(30,24): error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
12+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(33,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
1313
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"'.
14+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(37,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
1515
Type 'string | number' is not assignable to type '"name" | "width" | "height" | "visible"'.
1616
Type 'string' is not assignable to type '"name" | "width" | "height" | "visible"'.
1717
Type 'T' is not assignable to type '"visible"'.
1818
Type 'string | number' is not assignable to type '"visible"'.
1919
Type 'string' is not assignable to type '"visible"'.
20+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(59,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]?: T[P]; }'.
21+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(60,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]: T[P]; }'.
22+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(61,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]?: T[P]; }'.
23+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(66,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
2024

2125

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-
}
26+
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (13 errors) ====
3927

4028
interface Shape {
4129
name: string;
@@ -53,6 +41,8 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(51,24): error TS2344: T
5341
y: number;
5442
}
5543

44+
// Constraint checking
45+
5646
type T00 = { [P in P]: string }; // Error
5747
~
5848
!!! error TS2313: Type parameter 'P' has a circular constraint.
@@ -107,4 +97,33 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(51,24): error TS2344: T
10797

10898
function f4<T extends keyof Named>(x: T) {
10999
let y: Pick<Shape, T>;
100+
}
101+
102+
// Type identity checking
103+
104+
function f10<T>() {
105+
type K = keyof T;
106+
var x: { [P in keyof T]: T[P] };
107+
var x: { [Q in keyof T]: T[Q] };
108+
var x: { [R in K]: T[R] };
109+
}
110+
111+
function f11<T>() {
112+
var x: { [P in keyof T]: T[P] };
113+
var x: { [P in keyof T]?: T[P] }; // Error
114+
~
115+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]?: T[P]; }'.
116+
var x: { readonly [P in keyof T]: T[P] }; // Error
117+
~
118+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]: T[P]; }'.
119+
var x: { readonly [P in keyof T]?: T[P] }; // Error
120+
~
121+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]?: T[P]; }'.
122+
}
123+
124+
function f12<T>() {
125+
var x: { [P in keyof T]: T[P] };
126+
var x: { [P in keyof T]: T[P][] }; // Error
127+
~
128+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
110129
}

tests/baselines/reference/mappedTypeErrors.js

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
//// [mappedTypeErrors.ts]
22

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-
193
interface Shape {
204
name: string;
215
width: number;
@@ -32,6 +16,8 @@ interface Point {
3216
y: number;
3317
}
3418

19+
// Constraint checking
20+
3521
type T00 = { [P in P]: string }; // Error
3622
type T01 = { [P in Date]: number }; // Error
3723
type T02 = Record<Date, number>; // Error
@@ -58,6 +44,27 @@ function f3<T extends keyof Shape>(x: T) {
5844

5945
function f4<T extends keyof Named>(x: T) {
6046
let y: Pick<Shape, T>;
47+
}
48+
49+
// Type identity checking
50+
51+
function f10<T>() {
52+
type K = keyof T;
53+
var x: { [P in keyof T]: T[P] };
54+
var x: { [Q in keyof T]: T[Q] };
55+
var x: { [R in K]: T[R] };
56+
}
57+
58+
function f11<T>() {
59+
var x: { [P in keyof T]: T[P] };
60+
var x: { [P in keyof T]?: T[P] }; // Error
61+
var x: { readonly [P in keyof T]: T[P] }; // Error
62+
var x: { readonly [P in keyof T]?: T[P] }; // Error
63+
}
64+
65+
function f12<T>() {
66+
var x: { [P in keyof T]: T[P] };
67+
var x: { [P in keyof T]: T[P][] }; // Error
6168
}
6269

6370
//// [mappedTypeErrors.js]
@@ -73,21 +80,25 @@ function f3(x) {
7380
function f4(x) {
7481
var y;
7582
}
83+
// Type identity checking
84+
function f10() {
85+
var x;
86+
var x;
87+
var x;
88+
}
89+
function f11() {
90+
var x;
91+
var x; // Error
92+
var x; // Error
93+
var x; // Error
94+
}
95+
function f12() {
96+
var x;
97+
var x; // Error
98+
}
7699

77100

78101
//// [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-
};
91102
interface Shape {
92103
name: string;
93104
width: number;
@@ -119,3 +130,6 @@ declare function f1<T>(x: T): void;
119130
declare function f2<T extends string | number>(x: T): void;
120131
declare function f3<T extends keyof Shape>(x: T): void;
121132
declare function f4<T extends keyof Named>(x: T): void;
133+
declare function f10<T>(): void;
134+
declare function f11<T>(): void;
135+
declare function f12<T>(): void;

tests/baselines/reference/mappedTypes2.js

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
//// [mappedTypes2.ts]
22

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;
3+
function verifyLibTypes<T, K extends keyof T, U>() {
4+
var x1: Partial<T>;
5+
var x1: { [P in keyof T]?: T[P] };
6+
var x2: Readonly<T>;
7+
var x2: { readonly [P in keyof T]: T[P] };
8+
var x3: Pick<T, K>;
9+
var x3: { [P in K]: T[P] };
10+
var x4: Record<K, U>;
11+
var x4: { [P in K]: U };
1712
}
1813

1914
type Proxy<T> = {
@@ -95,6 +90,16 @@ function f6(shape: DeepReadonly<Shape>) {
9590
}
9691

9792
//// [mappedTypes2.js]
93+
function verifyLibTypes() {
94+
var x1;
95+
var x1;
96+
var x2;
97+
var x2;
98+
var x3;
99+
var x3;
100+
var x4;
101+
var x4;
102+
}
98103
function f0(s1, s2) {
99104
assign(s1, { name: "circle" });
100105
assign(s2, { width: 10, height: 20 });
@@ -129,18 +134,7 @@ function f6(shape) {
129134

130135

131136
//// [mappedTypes2.d.ts]
132-
declare type Partial<T> = {
133-
[P in keyof T]?: T[P];
134-
};
135-
declare type Readonly<T> = {
136-
readonly [P in keyof T]: T[P];
137-
};
138-
declare type Pick<T, K extends keyof T> = {
139-
[P in K]: T[P];
140-
};
141-
declare type Record<K extends string | number, T> = {
142-
[_ in K]: T;
143-
};
137+
declare function verifyLibTypes<T, K extends keyof T, U>(): void;
144138
declare type Proxy<T> = {
145139
get(): T;
146140
set(value: T): void;

0 commit comments

Comments
 (0)