Skip to content

Commit 11543d7

Browse files
committed
Accept new baselines
1 parent eebd67f commit 11543d7

18 files changed

+417
-172
lines changed

tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error T
33
Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ <U extends ReadonlyArray<B>>(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'.
44
Type 'A[]' is not assignable to type 'B[]'.
55
Type 'A' is not assignable to type 'B'.
6-
Property 'b' is missing in type 'A'.
76
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C<A>' is not assignable to type 'ReadonlyArray<B>'.
87
Types of property 'concat' are incompatible.
98
Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ <U extends ReadonlyArray<B>>(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'.
@@ -30,7 +29,6 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
3029
!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ <U extends ReadonlyArray<B>>(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'.
3130
!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'.
3231
!!! error TS2322: Type 'A' is not assignable to type 'B'.
33-
!!! error TS2322: Property 'b' is missing in type 'A'.
3432

3533
rra = cra;
3634
rra = crb; // OK, C<B> is assignable to ReadonlyArray<A>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(71,1): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
2+
Types of parameters 'y' and 'y' are incompatible.
3+
Types of parameters 'arg2' and 'arg2' are incompatible.
4+
Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
5+
Property 'bing' is missing in type 'Base'.
6+
7+
8+
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (1 errors) ====
9+
// these are all permitted with the current rules, since we do not do contextual signature instantiation
10+
11+
class Base { foo: string; }
12+
class Derived extends Base { bar: string; }
13+
class Derived2 extends Derived { baz: string; }
14+
class OtherDerived extends Base { bing: string; }
15+
16+
var a: (x: number) => number[];
17+
var a2: (x: number) => string[];
18+
var a3: (x: number) => void;
19+
var a4: (x: string, y: number) => string;
20+
var a5: (x: (arg: string) => number) => string;
21+
var a6: (x: (arg: Base) => Derived) => Base;
22+
var a7: (x: (arg: Base) => Derived) => (r: Base) => Derived;
23+
var a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
24+
var a9: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
25+
var a10: (...x: Derived[]) => Derived;
26+
var a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base;
27+
var a12: (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
28+
var a13: (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
29+
var a14: (x: { a: string; b: number }) => Object;
30+
var a15: {
31+
(x: number): number[];
32+
(x: string): string[];
33+
}
34+
var a16: {
35+
<T extends Derived>(x: T): number[];
36+
<U extends Base>(x: U): number[];
37+
}
38+
var a17: {
39+
(x: (a: number) => number): number[];
40+
(x: (a: string) => string): string[];
41+
};
42+
var a18: {
43+
(x: {
44+
(a: number): number;
45+
(a: string): string;
46+
}): any[];
47+
(x: {
48+
(a: boolean): boolean;
49+
(a: Date): Date;
50+
}): any[];
51+
}
52+
53+
var b: <T>(x: T) => T[];
54+
a = b; // ok
55+
b = a; // ok
56+
var b2: <T>(x: T) => string[];
57+
a2 = b2; // ok
58+
b2 = a2; // ok
59+
var b3: <T>(x: T) => T;
60+
a3 = b3; // ok
61+
b3 = a3; // ok
62+
var b4: <T, U>(x: T, y: U) => T;
63+
a4 = b4; // ok
64+
b4 = a4; // ok
65+
var b5: <T, U>(x: (arg: T) => U) => T;
66+
a5 = b5; // ok
67+
b5 = a5; // ok
68+
var b6: <T extends Base, U extends Derived>(x: (arg: T) => U) => T;
69+
a6 = b6; // ok
70+
b6 = a6; // ok
71+
var b7: <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U;
72+
a7 = b7; // ok
73+
b7 = a7; // ok
74+
var b8: <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U;
75+
a8 = b8; // ok
76+
b8 = a8; // ok
77+
var b9: <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U;
78+
a9 = b9; // ok
79+
b9 = a9; // ok
80+
~~
81+
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
82+
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
83+
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
84+
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
85+
!!! error TS2322: Property 'bing' is missing in type 'Base'.
86+
var b10: <T extends Derived>(...x: T[]) => T;
87+
a10 = b10; // ok
88+
b10 = a10; // ok
89+
var b11: <T extends Base>(x: T, y: T) => T;
90+
a11 = b11; // ok
91+
b11 = a11; // ok
92+
var b12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>;
93+
a12 = b12; // ok
94+
b12 = a12; // ok
95+
var b13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T;
96+
a13 = b13; // ok
97+
b13 = a13; // ok
98+
var b14: <T>(x: { a: T; b: T }) => T;
99+
a14 = b14; // ok
100+
b14 = a14; // ok
101+
var b15: <T>(x: T) => T[];
102+
a15 = b15; // ok
103+
b15 = a15; // ok
104+
var b16: <T extends Base>(x: T) => number[];
105+
a16 = b16; // ok
106+
b16 = a16; // ok
107+
var b17: <T>(x: (a: T) => T) => T[]; // ok
108+
a17 = b17; // ok
109+
b17 = a17; // ok
110+
var b18: <T>(x: (a: T) => T) => T[];
111+
a18 = b18; // ok
112+
b18 = a18; // ok
113+

tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(52,9): error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
22
Types of parameters 'y' and 'y' are incompatible.
3-
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
4-
Types of parameters 'arg2' and 'arg2' are incompatible.
5-
Type '{ foo: number; }' is not assignable to type 'Base'.
6-
Types of property 'foo' are incompatible.
7-
Type 'number' is not assignable to type 'string'.
3+
Types of parameters 'arg2' and 'arg2' are incompatible.
4+
Type '{ foo: number; }' is not assignable to type 'Base'.
5+
Types of property 'foo' are incompatible.
6+
Type 'number' is not assignable to type 'string'.
87
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
98
Types of parameters 'y' and 'y' are incompatible.
10-
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
11-
Types of parameters 'arg2' and 'arg2' are incompatible.
12-
Type 'Base' is not assignable to type '{ foo: number; }'.
13-
Types of property 'foo' are incompatible.
14-
Type 'string' is not assignable to type 'number'.
9+
Types of parameters 'arg2' and 'arg2' are incompatible.
10+
Type 'Base' is not assignable to type '{ foo: number; }'.
11+
Types of property 'foo' are incompatible.
12+
Type 'string' is not assignable to type 'number'.
1513

1614

1715
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (2 errors) ====
@@ -70,20 +68,18 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
7068
~~
7169
!!! error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
7270
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
73-
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
74-
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
75-
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
76-
!!! error TS2322: Types of property 'foo' are incompatible.
77-
!!! error TS2322: Type 'number' is not assignable to type 'string'.
71+
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
72+
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
73+
!!! error TS2322: Types of property 'foo' are incompatible.
74+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
7875
b8 = a8; // error, { foo: number } and Base are incompatible
7976
~~
8077
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
8178
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
82-
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
83-
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
84-
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
85-
!!! error TS2322: Types of property 'foo' are incompatible.
86-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
79+
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
80+
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
81+
!!! error TS2322: Types of property 'foo' are incompatible.
82+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
8783

8884

8985
var b10: <T extends Derived>(...x: T[]) => T;
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(71,1): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
2+
Types of parameters 'y' and 'y' are incompatible.
3+
Types of parameters 'arg2' and 'arg2' are incompatible.
4+
Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
5+
Property 'bing' is missing in type 'Base'.
6+
7+
8+
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (1 errors) ====
9+
// checking assignment compatibility relations for function types. All of these are valid.
10+
11+
class Base { foo: string; }
12+
class Derived extends Base { bar: string; }
13+
class Derived2 extends Derived { baz: string; }
14+
class OtherDerived extends Base { bing: string; }
15+
16+
var a: new (x: number) => number[];
17+
var a2: new (x: number) => string[];
18+
var a3: new (x: number) => void;
19+
var a4: new (x: string, y: number) => string;
20+
var a5: new (x: (arg: string) => number) => string;
21+
var a6: new (x: (arg: Base) => Derived) => Base;
22+
var a7: new (x: (arg: Base) => Derived) => (r: Base) => Derived;
23+
var a8: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
24+
var a9: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
25+
var a10: new (...x: Derived[]) => Derived;
26+
var a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base;
27+
var a12: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
28+
var a13: new (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
29+
var a14: new (x: { a: string; b: number }) => Object;
30+
var a15: {
31+
new (x: number): number[];
32+
new (x: string): string[];
33+
}
34+
var a16: {
35+
new <T extends Derived>(x: T): number[];
36+
new <U extends Base>(x: U): number[];
37+
}
38+
var a17: {
39+
new (x: new (a: number) => number): number[];
40+
new (x: new (a: string) => string): string[];
41+
};
42+
var a18: {
43+
new (x: {
44+
new (a: number): number;
45+
new (a: string): string;
46+
}): any[];
47+
new (x: {
48+
new (a: boolean): boolean;
49+
new (a: Date): Date;
50+
}): any[];
51+
}
52+
53+
var b: new <T>(x: T) => T[];
54+
a = b; // ok
55+
b = a; // ok
56+
var b2: new <T>(x: T) => string[];
57+
a2 = b2; // ok
58+
b2 = a2; // ok
59+
var b3: new <T>(x: T) => T;
60+
a3 = b3; // ok
61+
b3 = a3; // ok
62+
var b4: new <T, U>(x: T, y: U) => T;
63+
a4 = b4; // ok
64+
b4 = a4; // ok
65+
var b5: new <T, U>(x: (arg: T) => U) => T;
66+
a5 = b5; // ok
67+
b5 = a5; // ok
68+
var b6: new <T extends Base, U extends Derived>(x: (arg: T) => U) => T;
69+
a6 = b6; // ok
70+
b6 = a6; // ok
71+
var b7: new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U;
72+
a7 = b7; // ok
73+
b7 = a7; // ok
74+
var b8: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U;
75+
a8 = b8; // ok
76+
b8 = a8; // ok
77+
var b9: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U;
78+
a9 = b9; // ok
79+
b9 = a9; // ok
80+
~~
81+
!!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
82+
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
83+
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
84+
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
85+
!!! error TS2322: Property 'bing' is missing in type 'Base'.
86+
var b10: new <T extends Derived>(...x: T[]) => T;
87+
a10 = b10; // ok
88+
b10 = a10; // ok
89+
var b11: new <T extends Base>(x: T, y: T) => T;
90+
a11 = b11; // ok
91+
b11 = a11; // ok
92+
var b12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>;
93+
a12 = b12; // ok
94+
b12 = a12; // ok
95+
var b13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T;
96+
a13 = b13; // ok
97+
b13 = a13; // ok
98+
var b14: new <T>(x: { a: T; b: T }) => T;
99+
a14 = b14; // ok
100+
b14 = a14; // ok
101+
var b15: new <T>(x: T) => T[];
102+
a15 = b15; // ok
103+
b15 = a15; // ok
104+
var b16: new <T extends Base>(x: T) => number[];
105+
a16 = b16; // ok
106+
b16 = a16; // ok
107+
var b17: new <T>(x: new (a: T) => T) => T[]; // ok
108+
a17 = b17; // ok
109+
b17 = a17; // ok
110+
var b18: new <T>(x: new (a: T) => T) => T[];
111+
a18 = b18; // ok
112+
b18 = a18; // ok
113+

0 commit comments

Comments
 (0)