@cuppachino/type-space
Version:
A collection of type utilities for TypeScript.
10 lines (9 loc) • 402 B
TypeScript
/**
* Checks if a type extends a function or method.
*
* @param T - The type to check.
* @param R - The type to resolve to if `T` extends a function `(default: T)`.
* @see
* {@link https://github.com/Cuppachino/type-space/blob/main/src/extract/extract-functions.ts | ExtractFunctions } for example usage.
*/
export type ExtendsFunction<T, R = T> = T extends (...args: any[]) => any ? R : never;