How can I define a type in typescript so that I can e.g. all the first parameter types of a function type:
interface Foo {
(str: 'apple'|'banana'): void;
(str: 'hat'): void;
(x: number): void;
}
type ExtractAllParameters<T> = T extends (str: infer P ,...args: any) => any
? P : never;
so I would like to have ExtractAllParameters<Foo>
get resolved to something like:
'apple'|'banana'|'hat'|number
but I only get number
(since it’s the last call signature from the interface)