Skip to content

Commit 676892e

Browse files
committed
Add tests
1 parent 0e1b998 commit 676892e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// @strict: true
2+
// @declaration: true
3+
4+
declare let f1: (x: string, ...args: [string] | [number, boolean]) => void;
5+
declare let f2: (x: string, y: string) => void;
6+
declare let f3: (x: string, y: number, z: boolean) => void;
7+
declare let f4: (...args: [string, string] | [string, number, boolean]) => void;
8+
9+
declare const tt: [string] | [number, boolean];
10+
11+
f1("foo", "abc");
12+
f1("foo", 10, true);
13+
f1("foo", ...tt);
14+
f1("foo", 10); // Error
15+
f1("foo"); // Error
16+
17+
f2 = f1;
18+
f3 = f1;
19+
f4 = f1; // Error, misaligned complex rest types
20+
f1 = f2; // Error
21+
f1 = f3; // Error
22+
f1 = f4; // Error, misaligned complex rest types
23+
24+
// Repro from #26110
25+
26+
interface CoolArray<E> extends Array<E> {
27+
hello: number;
28+
}
29+
30+
declare function foo<T extends any[]>(cb: (...args: T) => void): void;
31+
32+
foo<CoolArray<any>>(); // Error
33+
foo<CoolArray<any>>(100); // Error
34+
foo<CoolArray<any>>(foo); // Error
35+
36+
function bar<T extends any[]>(...args: T): T {
37+
return args;
38+
}
39+
40+
let a = bar(10, 20);
41+
let b = bar<CoolArray<number>>(10, 20); // Error
42+
43+
declare function baz<T>(...args: CoolArray<T>): void;
44+
declare const ca: CoolArray<number>;
45+
46+
baz(); // Error
47+
baz(1); // Error
48+
baz(1, 2); // Error
49+
baz(...ca); // Error
50+
51+
// Repro from #26491
52+
53+
declare function hmm<A extends [] | [number, string]>(...args: A): void;
54+
hmm(); // okay, A = []
55+
hmm(1, "s"); // okay, A = [1, "s"]
56+
hmm("what"); // no error? A = [] | [number, string] ?

0 commit comments

Comments
 (0)