interface IComputable { add(x: T): T; sub(x: T): T; mul?(x: number): T; div?(x: T): number; div?(x: number): T; equals(x: object): boolean; compareTo(x: T): number; } interface IClonable { become(...args: any[]): T; clone(): T; } type PromisifiedFunction any> = (...args: Parameters) => ReturnType extends Promise ? ReturnType : Promise>; type UnPromisifiedFunction any> = (...args: Parameters) => ReturnType extends Promise ? P : ReturnType; type FunctionMap = Record any>; type PromisifiedFunctionMap = { [K in keyof T]: T[K] extends (...args: any[]) => any ? PromisifiedFunction : T[K]; }; type UnPromisifiedFunctionMap = { [K in keyof T]: T[K] extends (...args: any[]) => any ? UnPromisifiedFunction : T[K]; };