blob: 65c87ebf1cc1f6adcd43af1f631ea545f1224369 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/**
* Type that provides auto-suggestions but also any string.
*
* @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609
*/
export type LiteralUnion<T extends U, U = string> =
| T
| (U & { zz_IGNORE_ME?: never });
/**
* Type that represents a single method/function name of the given type.
*/
export type MethodOf<
ObjectType,
Signature extends (...args) => unknown = (...args) => unknown
> = {
[Key in keyof ObjectType]: ObjectType[Key] extends Signature ? Key : never;
}[keyof ObjectType];
/**
* Type that represents all method/function names of the given type.
*/
export type MethodsOf<
ObjectType,
Signature extends (...args) => unknown = (...args) => unknown
> = ReadonlyArray<MethodOf<ObjectType, Signature>>;
|