mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Add regression test
This commit is contained in:
parent
bac5f90af1
commit
d5f3cee35d
15
tests/cases/compiler/genericRestTypes.ts
Normal file
15
tests/cases/compiler/genericRestTypes.ts
Normal file
@ -0,0 +1,15 @@
|
||||
// @strict: true
|
||||
|
||||
// Repro from #25793
|
||||
|
||||
// Gets the parameters of a function type as a tuple
|
||||
type Parameters<T extends (...args: any[]) => any> = T extends (...args: infer U) => any ? U : never;
|
||||
// Removes the first element from a tuple
|
||||
type Tail<T extends any[]> = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never;
|
||||
|
||||
type MyFunctionType = (foo: number, bar: string) => boolean;
|
||||
|
||||
type Explicit = (...args: Tail<Parameters<MyFunctionType>>) => ReturnType<MyFunctionType>; // (bar: string) => boolean
|
||||
|
||||
type Bind1<T extends (head: any, ...tail: any[]) => any> = (...args: Tail<Parameters<T>>) => ReturnType<T>;
|
||||
type Generic = Bind1<MyFunctionType>; // (bar: string) => boolean
|
||||
Loading…
x
Reference in New Issue
Block a user