type Foo < T extends unknown [ ] > = [ string , ... T , number ] ; type T1 = Foo < [ boolean ] > ; type T2 = Foo < [ number , number ] > ; type T3 = Foo < [ ] > ; function concat < T extends unknown [ ] , U extends unknown [ ] > ( t , u ) { return [ ... t , ... u ] ; } const ns = [ 0 , 1 , 2 , 3 ] ; const t1 = concat ( [ 1 , 2 ] , [ 'hello' ] ) ; const t2 = concat ( [ true ] , t1 ) ; const t3 = concat ( [ true ] , ns ) ; declare function last < T extends unknown [ ] , U > ( a ) ; const a = [ 'hello' , 'world' , 42 ] ; last ( [ 'foo' , 42 , true ] ) ; last ( [ 'foo' , 42 ] ) ; last ( [ 'foo' ] ) ; last ( a ) ; type Head < T extends readonly unknown [ ] > = T [ 0 ] ; type Tail < T extends readonly unknown [ ] > = T extends readonly [ any , ... infer U ] ? U : [ ... T ] ; type Init < T extends readonly unknown [ ] > = T extends readonly [ ... infer U , any ] ? U : [ ... T ] ; type Last < T extends readonly unknown [ ] > = T extends readonly [ ... infer _ , infer U ] ? U : undefined ; type TS1 = Head < [ number , string , boolean ] > ; type TS2 = Tail < [ number , string , boolean ] > ; type TS3 = Init < [ number , string , boolean ] > ; type TS4 = Last < [ number , string , boolean ] > ; function bind < T extends unknown [ ] , U extends unknown [ ] , R > ( f , ... a ) { return ( ... b ) => f ( ... a , ... b ) ; } const fn1 = ( a , b , c , d ) => 0 ; const c0 = bind ( fn1 ) ; const c1 = bind ( fn1 , 1 ) ; const c2 = bind ( fn1 , 1 , 'abc' ) ; const c3 = bind ( fn1 , 1 , 'abc' , true ) ; const c4 = bind ( fn1 , 1 , 'abc' , true , [ 'x' , 'y' ] ) ; type Callback < A extends unknown [ ] > = ( context : unknown , ... args : A ) => void ; type CB1 = Callback < [ string ] > ; type CB2 = Callback < [ number , number ] > ; type F1 = ( x : number , y : number ) => void ; type P1 = Parameters < F1 > ; type CB3 = Callback < P1 > ; declare let cb1 ; declare let cb2 ; cb1 ( undefined , 'hello' ) ; cb2 ( undefined , 1 , 2 ) ; function foo3 < T extends unknown [ ] , U extends unknown [ ] > ( t , u ) { return [ 1 , ... t , 2 , ... u , 3 ] as const ; } const t = foo3 ( [ 'hello' ] , [ 10 , true ] ) ; declare function fs1 ( a , b , c , ... d ) ; function fs2 ( t1 , t2 , a1 ) { fs1 ( 1 , 'abc' , true , 42 , 43 , 44 ) ; fs1 ( ... t1 , true , 42 , 43 , 44 ) ; fs1 ( ... t1 , ... t2 , 42 , 43 , 44 ) ; fs1 ( ... t1 , ... t2 , ... a1 ) ; fs1 ( ... t1 ) ; fs1 ( ... t1 , 45 ) ; }