Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x | export type Constructor<T = object> = new (...args: unknown[]) => T;
export function isConstructor<T = unknown>(
value: unknown
): value is Constructor<T> {
return (
!!value &&
typeof value === 'object' &&
'prototype' in value &&
typeof value.prototype === 'object' &&
!!value.prototype &&
'constructor' in value.prototype.constructor
);
}
/**
* @see {@link https://stackoverflow.com/a/69571314/294171 StackOverflow response} on static interfaces
*
* ```ts
* interface InstanceInterface {
* instanceMethod();
* }
*
* interface StaticInterface {
* new(...args: any[]): InstanceInterface;
* staticMethod();
* }
*
* class MyClass implements StaticImplements<StaticInterface, typeof MyClass> {
* static staticMethod() { }
* static ownStaticMethod() { }
* instanceMethod() { }
* ownInstanceMethod() { }
* }
* ```
*/
export type StaticImplements<
I extends new (...args: unknown[]) => object,
C extends I
> = InstanceType<C>;
|