type T0 = [ number , ... string [ ] ] ; type T1 = [ ... string [ ] , number ] ; type T2 = [ number , ... boolean [ ] , string , string ] ; function foo ( ... args ) { const strs = args . slice ( 0 , - 1 ) as string [ ] ; const num = args [ args . length - 1 ] as number ; } foo ( 5 ) ; foo ( 'abc' , 5 ) ; foo ( 'abc' , 'def' , 5 ) ; foo ( 'abc' , 'def' , 5 , 6 ) ; declare function curryLast < T extends unknown [ ] , U , V > ( f , last ) ; declare function f3 ( s , n , b ) ; const f2 = curryLast ( f3 , true ) ;