Type alias Methods<T>

Methods<T>: {
    [K in Keys<T>]-?: ExcludeNullable<T[K]> extends AnyFunction
        ? K
        : never
}[Keys<T>]

Get the literal names of keys that are methods in object type T

Type Parameters

  • T extends object

Example

Methods<{
foo: () => void;
bar: (a: any) => string;
barBaz: string;
bazBar: Numeric;
}> // Result: 'foo' | 'bar'