Skip to content

Commit beb241d

Browse files
committed
add tests from microsoft#45972
1 parent 0de8923 commit beb241d

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

tests/baselines/reference/restTupleUnionWithRestContextualParams.symbols

+46
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,49 @@ const f4: (...args: [type: "one", x?: number] | [type: "two", x: string]) => voi
2626
>type : Symbol(type, Decl(restTupleUnionWithRestContextualParams.ts, 6, 85))
2727
>x : Symbol(x, Decl(restTupleUnionWithRestContextualParams.ts, 6, 90))
2828

29+
// #45972
30+
type Fn1 = (...args: [...strs: string[], num1: number, num2: number]) => void;
31+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
32+
>args : Symbol(args, Decl(restTupleUnionWithRestContextualParams.ts, 9, 12))
33+
34+
const f5: Fn1 = () => {}
35+
>f5 : Symbol(f5, Decl(restTupleUnionWithRestContextualParams.ts, 10, 5))
36+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
37+
38+
const f6: Fn1 = (arg1) => {}
39+
>f6 : Symbol(f6, Decl(restTupleUnionWithRestContextualParams.ts, 11, 5))
40+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
41+
>arg1 : Symbol(arg1, Decl(restTupleUnionWithRestContextualParams.ts, 11, 17))
42+
43+
const f7: Fn1 = (arg1, arg2) => {}
44+
>f7 : Symbol(f7, Decl(restTupleUnionWithRestContextualParams.ts, 12, 5))
45+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
46+
>arg1 : Symbol(arg1, Decl(restTupleUnionWithRestContextualParams.ts, 12, 17))
47+
>arg2 : Symbol(arg2, Decl(restTupleUnionWithRestContextualParams.ts, 12, 22))
48+
49+
const f8: Fn1 = (arg1, arg2, arg3) => {}
50+
>f8 : Symbol(f8, Decl(restTupleUnionWithRestContextualParams.ts, 13, 5))
51+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
52+
>arg1 : Symbol(arg1, Decl(restTupleUnionWithRestContextualParams.ts, 13, 17))
53+
>arg2 : Symbol(arg2, Decl(restTupleUnionWithRestContextualParams.ts, 13, 22))
54+
>arg3 : Symbol(arg3, Decl(restTupleUnionWithRestContextualParams.ts, 13, 28))
55+
56+
// #45972#issuecomment-1140417029
57+
const f9: Fn1 = (...[arg1]: [string | number]) => {}
58+
>f9 : Symbol(f9, Decl(restTupleUnionWithRestContextualParams.ts, 16, 5))
59+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
60+
>arg1 : Symbol(arg1, Decl(restTupleUnionWithRestContextualParams.ts, 16, 21))
61+
62+
const f10: Fn1 = (...[arg1, arg2]: [string | number, string | number]) => {}
63+
>f10 : Symbol(f10, Decl(restTupleUnionWithRestContextualParams.ts, 17, 5))
64+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
65+
>arg1 : Symbol(arg1, Decl(restTupleUnionWithRestContextualParams.ts, 17, 22))
66+
>arg2 : Symbol(arg2, Decl(restTupleUnionWithRestContextualParams.ts, 17, 27))
67+
68+
const f11: Fn1 = (...[arg1, arg2, arg3]: [string | number, string | number, string | number]) => {}
69+
>f11 : Symbol(f11, Decl(restTupleUnionWithRestContextualParams.ts, 18, 5))
70+
>Fn1 : Symbol(Fn1, Decl(restTupleUnionWithRestContextualParams.ts, 6, 99))
71+
>arg1 : Symbol(arg1, Decl(restTupleUnionWithRestContextualParams.ts, 18, 22))
72+
>arg2 : Symbol(arg2, Decl(restTupleUnionWithRestContextualParams.ts, 18, 27))
73+
>arg3 : Symbol(arg3, Decl(restTupleUnionWithRestContextualParams.ts, 18, 33))
74+

tests/baselines/reference/restTupleUnionWithRestContextualParams.types

+46
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,49 @@ const f4: (...args: [type: "one", x?: number] | [type: "two", x: string]) => voi
3030
>type : "one" | "two"
3131
>x : string | number | undefined
3232

33+
// #45972
34+
type Fn1 = (...args: [...strs: string[], num1: number, num2: number]) => void;
35+
>Fn1 : (...args: [...strs: string[], num1: number, num2: number]) => void
36+
>args : [...strs: string[], num1: number, num2: number]
37+
38+
const f5: Fn1 = () => {}
39+
>f5 : Fn1
40+
>() => {} : () => void
41+
42+
const f6: Fn1 = (arg1) => {}
43+
>f6 : Fn1
44+
>(arg1) => {} : (arg1: string | number) => void
45+
>arg1 : string | number
46+
47+
const f7: Fn1 = (arg1, arg2) => {}
48+
>f7 : Fn1
49+
>(arg1, arg2) => {} : (arg1: string | number, arg2: string | number) => void
50+
>arg1 : string | number
51+
>arg2 : string | number
52+
53+
const f8: Fn1 = (arg1, arg2, arg3) => {}
54+
>f8 : Fn1
55+
>(arg1, arg2, arg3) => {} : (arg1: string | number, arg2: string | number, arg3: string | number) => void
56+
>arg1 : string | number
57+
>arg2 : string | number
58+
>arg3 : string | number
59+
60+
// #45972#issuecomment-1140417029
61+
const f9: Fn1 = (...[arg1]: [string | number]) => {}
62+
>f9 : Fn1
63+
>(...[arg1]: [string | number]) => {} : (__0_0: string | number) => void
64+
>arg1 : string | number
65+
66+
const f10: Fn1 = (...[arg1, arg2]: [string | number, string | number]) => {}
67+
>f10 : Fn1
68+
>(...[arg1, arg2]: [string | number, string | number]) => {} : (__0_0: string | number, __0_1: string | number) => void
69+
>arg1 : string | number
70+
>arg2 : string | number
71+
72+
const f11: Fn1 = (...[arg1, arg2, arg3]: [string | number, string | number, string | number]) => {}
73+
>f11 : Fn1
74+
>(...[arg1, arg2, arg3]: [string | number, string | number, string | number]) => {} : (__0_0: string | number, __0_1: string | number, __0_2: string | number) => void
75+
>arg1 : string | number
76+
>arg2 : string | number
77+
>arg3 : string | number
78+

tests/cases/compiler/restTupleUnionWithRestContextualParams.ts

+12
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ const f2: (x: string, ...args: [string] | [number, boolean]) => void = (a, b, c)
88
const f3: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {}
99

1010
const f4: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {}
11+
12+
// #45972
13+
type Fn1 = (...args: [...strs: string[], num1: number, num2: number]) => void;
14+
const f5: Fn1 = () => {}
15+
const f6: Fn1 = (arg1) => {}
16+
const f7: Fn1 = (arg1, arg2) => {}
17+
const f8: Fn1 = (arg1, arg2, arg3) => {}
18+
19+
// #45972#issuecomment-1140417029
20+
const f9: Fn1 = (...[arg1]: [string | number]) => {}
21+
const f10: Fn1 = (...[arg1, arg2]: [string | number, string | number]) => {}
22+
const f11: Fn1 = (...[arg1, arg2, arg3]: [string | number, string | number, string | number]) => {}

0 commit comments

Comments
 (0)