|
| 1 | +// @strict: true |
| 2 | +// @declaration: true |
| 3 | + |
| 4 | +declare const t1: [number, string, ...boolean[]]; |
| 5 | +declare const t2: [string, ...boolean[]]; |
| 6 | +declare const t3: [...boolean[]]; |
| 7 | +declare const t4: []; |
| 8 | + |
| 9 | +declare let f00: (...x: [number, string, boolean]) => void; |
| 10 | +declare let f01: (a: number, ...x: [string, boolean]) => void; |
| 11 | +declare let f02: (a: number, b: string, ...x: [boolean]) => void; |
| 12 | +declare let f03: (a: number, b: string, c: boolean) => void; |
| 13 | +declare let f04: (a: number, b: string, c: boolean, ...x: []) => void; |
| 14 | + |
| 15 | +declare let f10: (...x: [number, string, ...boolean[]]) => void; |
| 16 | +declare let f11: (a: number, ...x: [string, ...boolean[]]) => void; |
| 17 | +declare let f12: (a: number, b: string, ...x: [...boolean[]]) => void; |
| 18 | +declare let f13: (a: number, b: string, ...c: boolean[]) => void; |
| 19 | + |
| 20 | +declare const ns: [number, string]; |
| 21 | +declare const sn: [string, number]; |
| 22 | + |
| 23 | +f10(42, "hello"); |
| 24 | +f10(42, "hello", true); |
| 25 | +f10(42, "hello", true, false); |
| 26 | +f10(t1[0], t1[1], t1[2], t1[3]); |
| 27 | +f10(...t1); |
| 28 | +f10(42, ...t2); |
| 29 | +f10(42, "hello", ...t3); |
| 30 | +f10(42, "hello", true, ...t4); |
| 31 | +f10(42, "hello", true, ...t4, false, ...t3); |
| 32 | + |
| 33 | +f11(42, "hello"); |
| 34 | +f11(42, "hello", true); |
| 35 | +f11(42, "hello", true, false); |
| 36 | +f11(t1[0], t1[1], t1[2], t1[3]); |
| 37 | +f11(...t1); |
| 38 | +f11(42, ...t2); |
| 39 | +f11(42, "hello", ...t3); |
| 40 | +f11(42, "hello", true, ...t4); |
| 41 | +f11(42, "hello", true, ...t4, false, ...t3); |
| 42 | + |
| 43 | +f12(42, "hello"); |
| 44 | +f12(42, "hello", true); |
| 45 | +f12(42, "hello", true, false); |
| 46 | +f12(t1[0], t1[1], t1[2], t1[3]); |
| 47 | +f12(...t1); |
| 48 | +f12(42, ...t2); |
| 49 | +f12(42, "hello", ...t3); |
| 50 | +f12(42, "hello", true, ...t4); |
| 51 | +f12(42, "hello", true, ...t4, false, ...t3); |
| 52 | + |
| 53 | +f13(42, "hello"); |
| 54 | +f13(42, "hello", true); |
| 55 | +f13(42, "hello", true, false); |
| 56 | +f13(t1[0], t1[1], t1[2], t1[3]); |
| 57 | +f13(...t1); |
| 58 | +f13(42, ...t2); |
| 59 | +f13(42, "hello", ...t3); |
| 60 | +f13(42, "hello", true, ...t4); |
| 61 | +f13(42, "hello", true, ...t4, false, ...t3); |
| 62 | + |
| 63 | +declare const f20: <T extends unknown[]>(...args: T) => T; |
| 64 | + |
| 65 | +f20(...t1); |
| 66 | +f20(42, ...t2); |
| 67 | +f20(42, "hello", ...t3); |
| 68 | +f20(42, "hello", ...t2, true); |
| 69 | + |
| 70 | +type Parameters<T extends Function> = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; |
| 71 | + |
| 72 | +type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; |
| 73 | +type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; |
| 74 | +type T03 = Parameters<new (x: number, y: string, ...z: boolean[]) => void>; |
| 75 | +type T04 = Parameters<new (...args: [number, string, ...boolean[]]) => void>; |
| 76 | +type T05<T extends any[]> = Parameters<(x: string, ...args: T) => void>; |
| 77 | +type T06 = T05<[number, ...boolean[]]>; |
| 78 | + |
| 79 | +type P1<T extends Function> = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[]; |
| 80 | + |
| 81 | +type T10 = P1<(x: number, y: string, ...z: boolean[]) => void>; |
| 82 | +type T11 = P1<(...z: number[]) => void>; |
| 83 | +type T12 = P1<(x: number, y: number) => void>; |
0 commit comments