Skip to content

Commit a597d3c

Browse files
committed
Accept new baselines
1 parent 6cd7454 commit a597d3c

File tree

5 files changed

+255
-4
lines changed

5 files changed

+255
-4
lines changed

tests/baselines/reference/mappedTypeErrors.errors.txt

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(124,12): error TS2345:
3636
Type 'undefined' is not assignable to type 'string'.
3737
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(125,14): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
3838
Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
39+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(129,5): error TS2322: Type '{ a: string; }' is not assignable to type 'T2'.
40+
Types of property 'a' are incompatible.
41+
Type 'string' is not assignable to type 'number | undefined'.
42+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,5): error TS2322: Type '{ a: string; }' is not assignable to type 'Partial<T2>'.
43+
Types of property 'a' are incompatible.
44+
Type 'string' is not assignable to type 'number | undefined'.
45+
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(131,5): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'.
46+
Types of property 'a' are incompatible.
47+
Type 'string' is not assignable to type 'number | undefined'.
3948

4049

41-
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (21 errors) ====
50+
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (24 errors) ====
4251

4352
interface Shape {
4453
name: string;
@@ -223,4 +232,21 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(125,14): error TS2345:
223232
~~~~~~~
224233
!!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
225234
!!! error TS2345: Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
226-
235+
236+
type T2 = { a?: number, [key: string]: any };
237+
238+
let x1: T2 = { a: 'no' }; // Error
239+
~~
240+
!!! error TS2322: Type '{ a: string; }' is not assignable to type 'T2'.
241+
!!! error TS2322: Types of property 'a' are incompatible.
242+
!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'.
243+
let x2: Partial<T2> = { a: 'no' }; // Error
244+
~~
245+
!!! error TS2322: Type '{ a: string; }' is not assignable to type 'Partial<T2>'.
246+
!!! error TS2322: Types of property 'a' are incompatible.
247+
!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'.
248+
let x3: { [P in keyof T2]: T2[P]} = { a: 'no' }; // Error
249+
~~
250+
!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'.
251+
!!! error TS2322: Types of property 'a' are incompatible.
252+
!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'.

tests/baselines/reference/mappedTypeErrors.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ c.setState({ });
124124
c.setState(foo);
125125
c.setState({ a: undefined }); // Error
126126
c.setState({ c: true }); // Error
127-
127+
128+
type T2 = { a?: number, [key: string]: any };
129+
130+
let x1: T2 = { a: 'no' }; // Error
131+
let x2: Partial<T2> = { a: 'no' }; // Error
132+
let x3: { [P in keyof T2]: T2[P]} = { a: 'no' }; // Error
128133

129134
//// [mappedTypeErrors.js]
130135
function f1(x) {
@@ -196,6 +201,9 @@ c.setState({});
196201
c.setState(foo);
197202
c.setState({ a: undefined }); // Error
198203
c.setState({ c: true }); // Error
204+
var x1 = { a: 'no' }; // Error
205+
var x2 = { a: 'no' }; // Error
206+
var x3 = { a: 'no' }; // Error
199207

200208

201209
//// [mappedTypeErrors.d.ts]
@@ -251,3 +259,12 @@ declare class C<T> {
251259
setState<K extends keyof T>(props: Pick<T, K>): void;
252260
}
253261
declare let c: C<Foo>;
262+
declare type T2 = {
263+
a?: number;
264+
[key: string]: any;
265+
};
266+
declare let x1: T2;
267+
declare let x2: Partial<T2>;
268+
declare let x3: {
269+
[P in keyof T2]: T2[P];
270+
};

tests/baselines/reference/mappedTypeModifiers.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,30 @@ var b04: Readonly<BP>;
7474
var b04: Partial<Readonly<B>>;
7575
var b04: Readonly<Partial<B>>;
7676
var b04: { [P in keyof BPR]: BPR[P] }
77-
var b04: Pick<BPR, keyof BPR>;
77+
var b04: Pick<BPR, keyof BPR>;
78+
79+
type Foo = { prop: number, [x: string]: number };
80+
81+
function f1(x: Partial<Foo>) {
82+
x.prop; // ok
83+
(x["other"] || 0).toFixed();
84+
}
85+
86+
function f2(x: Readonly<Foo>) {
87+
x.prop; // ok
88+
x["other"].toFixed();
89+
}
90+
91+
function f3(x: Boxified<Foo>) {
92+
x.prop; // ok
93+
x["other"].x.toFixed();
94+
}
95+
96+
function f4(x: { [P in keyof Foo]: Foo[P] }) {
97+
x.prop; // ok
98+
x["other"].toFixed();
99+
}
100+
78101

79102
//// [mappedTypeModifiers.js]
80103
var v00;
@@ -131,3 +154,19 @@ var b04;
131154
var b04;
132155
var b04;
133156
var b04;
157+
function f1(x) {
158+
x.prop; // ok
159+
(x["other"] || 0).toFixed();
160+
}
161+
function f2(x) {
162+
x.prop; // ok
163+
x["other"].toFixed();
164+
}
165+
function f3(x) {
166+
x.prop; // ok
167+
x["other"].x.toFixed();
168+
}
169+
function f4(x) {
170+
x.prop; // ok
171+
x["other"].toFixed();
172+
}

tests/baselines/reference/mappedTypeModifiers.symbols

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,80 @@ var b04: Pick<BPR, keyof BPR>;
353353
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
354354
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
355355

356+
type Foo = { prop: number, [x: string]: number };
357+
>Foo : Symbol(Foo, Decl(mappedTypeModifiers.ts, 75, 30))
358+
>prop : Symbol(prop, Decl(mappedTypeModifiers.ts, 77, 12))
359+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 77, 28))
360+
361+
function f1(x: Partial<Foo>) {
362+
>f1 : Symbol(f1, Decl(mappedTypeModifiers.ts, 77, 49))
363+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 79, 12))
364+
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
365+
>Foo : Symbol(Foo, Decl(mappedTypeModifiers.ts, 75, 30))
366+
367+
x.prop; // ok
368+
>x.prop : Symbol(prop)
369+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 79, 12))
370+
>prop : Symbol(prop)
371+
372+
(x["other"] || 0).toFixed();
373+
>(x["other"] || 0).toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
374+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 79, 12))
375+
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
376+
}
377+
378+
function f2(x: Readonly<Foo>) {
379+
>f2 : Symbol(f2, Decl(mappedTypeModifiers.ts, 82, 1))
380+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 84, 12))
381+
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
382+
>Foo : Symbol(Foo, Decl(mappedTypeModifiers.ts, 75, 30))
383+
384+
x.prop; // ok
385+
>x.prop : Symbol(prop)
386+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 84, 12))
387+
>prop : Symbol(prop)
388+
389+
x["other"].toFixed();
390+
>x["other"].toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
391+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 84, 12))
392+
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
393+
}
394+
395+
function f3(x: Boxified<Foo>) {
396+
>f3 : Symbol(f3, Decl(mappedTypeModifiers.ts, 87, 1))
397+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 89, 12))
398+
>Boxified : Symbol(Boxified, Decl(mappedTypeModifiers.ts, 36, 28))
399+
>Foo : Symbol(Foo, Decl(mappedTypeModifiers.ts, 75, 30))
400+
401+
x.prop; // ok
402+
>x.prop : Symbol(prop)
403+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 89, 12))
404+
>prop : Symbol(prop)
405+
406+
x["other"].x.toFixed();
407+
>x["other"].x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
408+
>x["other"].x : Symbol(x, Decl(mappedTypeModifiers.ts, 38, 38))
409+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 89, 12))
410+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 38, 38))
411+
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
412+
}
413+
414+
function f4(x: { [P in keyof Foo]: Foo[P] }) {
415+
>f4 : Symbol(f4, Decl(mappedTypeModifiers.ts, 92, 1))
416+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 94, 12))
417+
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 94, 18))
418+
>Foo : Symbol(Foo, Decl(mappedTypeModifiers.ts, 75, 30))
419+
>Foo : Symbol(Foo, Decl(mappedTypeModifiers.ts, 75, 30))
420+
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 94, 18))
421+
422+
x.prop; // ok
423+
>x.prop : Symbol(prop)
424+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 94, 12))
425+
>prop : Symbol(prop)
426+
427+
x["other"].toFixed();
428+
>x["other"].toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
429+
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 94, 12))
430+
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
431+
}
432+

tests/baselines/reference/mappedTypeModifiers.types

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,95 @@ var b04: Pick<BPR, keyof BPR>;
353353
>BPR : BPR
354354
>BPR : BPR
355355

356+
type Foo = { prop: number, [x: string]: number };
357+
>Foo : Foo
358+
>prop : number
359+
>x : string
360+
361+
function f1(x: Partial<Foo>) {
362+
>f1 : (x: Partial<Foo>) => void
363+
>x : Partial<Foo>
364+
>Partial : Partial<T>
365+
>Foo : Foo
366+
367+
x.prop; // ok
368+
>x.prop : number | undefined
369+
>x : Partial<Foo>
370+
>prop : number | undefined
371+
372+
(x["other"] || 0).toFixed();
373+
>(x["other"] || 0).toFixed() : string
374+
>(x["other"] || 0).toFixed : (fractionDigits?: number | undefined) => string
375+
>(x["other"] || 0) : number
376+
>x["other"] || 0 : number
377+
>x["other"] : number | undefined
378+
>x : Partial<Foo>
379+
>"other" : "other"
380+
>0 : 0
381+
>toFixed : (fractionDigits?: number | undefined) => string
382+
}
383+
384+
function f2(x: Readonly<Foo>) {
385+
>f2 : (x: Readonly<Foo>) => void
386+
>x : Readonly<Foo>
387+
>Readonly : Readonly<T>
388+
>Foo : Foo
389+
390+
x.prop; // ok
391+
>x.prop : number
392+
>x : Readonly<Foo>
393+
>prop : number
394+
395+
x["other"].toFixed();
396+
>x["other"].toFixed() : string
397+
>x["other"].toFixed : (fractionDigits?: number | undefined) => string
398+
>x["other"] : number
399+
>x : Readonly<Foo>
400+
>"other" : "other"
401+
>toFixed : (fractionDigits?: number | undefined) => string
402+
}
403+
404+
function f3(x: Boxified<Foo>) {
405+
>f3 : (x: Boxified<Foo>) => void
406+
>x : Boxified<Foo>
407+
>Boxified : Boxified<T>
408+
>Foo : Foo
409+
410+
x.prop; // ok
411+
>x.prop : { x: number; }
412+
>x : Boxified<Foo>
413+
>prop : { x: number; }
414+
415+
x["other"].x.toFixed();
416+
>x["other"].x.toFixed() : string
417+
>x["other"].x.toFixed : (fractionDigits?: number | undefined) => string
418+
>x["other"].x : number
419+
>x["other"] : { x: number; }
420+
>x : Boxified<Foo>
421+
>"other" : "other"
422+
>x : number
423+
>toFixed : (fractionDigits?: number | undefined) => string
424+
}
425+
426+
function f4(x: { [P in keyof Foo]: Foo[P] }) {
427+
>f4 : (x: { [x: string]: number; prop: number; }) => void
428+
>x : { [x: string]: number; prop: number; }
429+
>P : P
430+
>Foo : Foo
431+
>Foo : Foo
432+
>P : P
433+
434+
x.prop; // ok
435+
>x.prop : number
436+
>x : { [x: string]: number; prop: number; }
437+
>prop : number
438+
439+
x["other"].toFixed();
440+
>x["other"].toFixed() : string
441+
>x["other"].toFixed : (fractionDigits?: number | undefined) => string
442+
>x["other"] : number
443+
>x : { [x: string]: number; prop: number; }
444+
>"other" : "other"
445+
>toFixed : (fractionDigits?: number | undefined) => string
446+
}
447+

0 commit comments

Comments
 (0)