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>;
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
Playground link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With