Skip to content

Commit 0e1b998

Browse files
committed
Accept new baselines
1 parent f5f6133 commit 0e1b998

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'.
2+
Types of parameters 'b' and 'args' are incompatible.
3+
Type 'T' is not assignable to type '[any, ...any[]]'.
4+
Type 'any[]' is not assignable to type '[any, ...any[]]'.
5+
Property '0' is missing in type 'any[]'.
6+
7+
8+
==== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts (1 errors) ====
9+
declare const t1: [number, boolean, string];
10+
11+
(function (a, b, c){})(...t1);
12+
(function (...x){})(...t1);
13+
(function (a, ...x){})(...t1);
14+
(function (a, b, ...x){})(...t1);
15+
(function (a, b, c, ...x){})(...t1);
16+
17+
declare function f1(cb: (...args: typeof t1) => void): void;
18+
19+
f1((a, b, c) => {})
20+
f1((...x) => {})
21+
f1((a, ...x) => {})
22+
f1((a, b, ...x) => {})
23+
f1((a, b, c, ...x) => {})
24+
25+
declare const t2: [number, boolean, ...string[]];
26+
27+
(function (a, b, c){})(...t2);
28+
(function (...x){})(...t2);
29+
(function (a, ...x){})(...t2);
30+
(function (a, b, ...x){})(...t2);
31+
(function (a, b, c, ...x){})(...t2);
32+
33+
declare function f2(cb: (...args: typeof t2) => void): void;
34+
35+
f2((a, b, c) => {})
36+
f2((...x) => {})
37+
f2((a, ...x) => {})
38+
f2((a, b, ...x) => {})
39+
f2((a, b, c, ...x) => {})
40+
41+
declare const t3: [boolean, ...string[]];
42+
43+
(function (a, b, c){})(1, ...t3);
44+
(function (...x){})(1, ...t3);
45+
(function (a, ...x){})(1, ...t3);
46+
(function (a, b, ...x){})(1, ...t3);
47+
(function (a, b, c, ...x){})(1, ...t3);
48+
49+
declare function f3(cb: (x: number, ...args: typeof t3) => void): void;
50+
51+
f3((a, b, c) => {})
52+
f3((...x) => {})
53+
f3((a, ...x) => {})
54+
f3((a, b, ...x) => {})
55+
f3((a, b, c, ...x) => {})
56+
57+
function f4<T extends any[]>(t: T) {
58+
(function(...x){})(...t);
59+
(function(a, ...x){})(1, ...t);
60+
(function(a, ...x){})(1, 2, ...t);
61+
function f(cb: (x: number, ...args: T) => void) {}
62+
f((...x) => {});
63+
f((a, ...x) => {});
64+
f((a, b, ...x) => {});
65+
~~~~~~~~~~~~~~~~~~
66+
!!! error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'.
67+
!!! error TS2345: Types of parameters 'b' and 'args' are incompatible.
68+
!!! error TS2345: Type 'T' is not assignable to type '[any, ...any[]]'.
69+
!!! error TS2345: Type 'any[]' is not assignable to type '[any, ...any[]]'.
70+
!!! error TS2345: Property '0' is missing in type 'any[]'.
71+
}
72+
73+
// Repro from #25288
74+
75+
declare var tuple: [number, string];
76+
(function foo(a, b){}(...tuple));
77+
78+
// Repro from #25289
79+
80+
declare function take(cb: (a: number, b: string) => void): void;
81+
82+
(function foo(...rest){}(1, ''));
83+
take(function(...rest){});
84+

0 commit comments

Comments
 (0)