There is a function interface with statics:
interface MyFunction {
(value: string): string;
a: string;
b: string;
}
How do I Pick the call signature only (ignore a and b)?
You cannot Pick a call signature as it is not a property of your interface.
You can do next:
interface MyFunction {
(value: string): string;
a: string;
b: string;
}
type Callable<T> = T extends (...args: any[]) => any ? (...args: Parameters<T>) => ReturnType<T> : never;
type MyFunctionCallSignature = Callable<MyFunction>;
Parameters existed. When did it get introduced ?You can't Pick it because you can't pass a string key that will select it, however here are constructed types that will infer the correct type of your Function :
interface MyFunction {
(value: string): string;
a: string;
b: string;
}
type SignatureType<T> = T extends (...args: infer R) => any ? R : never;
type CallableType<T extends (...args: any[]) => any> = (...args: SignatureType<T>) => ReturnType<T>;
type CallableOfMyFunction = CallableType<MyFunction>; // Type (value: string) => string