ver
This commit is contained in:
21
types/Common/Singleton.d.ts
vendored
Normal file
21
types/Common/Singleton.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export interface PrototypeType<T> extends Function {
|
||||
prototype: T;
|
||||
}
|
||||
export interface ConstructorFunctionType<T = any> extends PrototypeType<T> {
|
||||
new (...args: any[]): T;
|
||||
}
|
||||
export type ConstructorType<T = unknown, Static extends Record<string, any> = PrototypeType<T>> = (ConstructorFunctionType<T> | PrototypeType<T>) & {
|
||||
[Key in keyof Static]: Static[Key];
|
||||
};
|
||||
/**
|
||||
* 构造单例类的静态类.
|
||||
* # Example:
|
||||
* class A extends Singleton(){};
|
||||
* //获得单例
|
||||
* let a = A.GetInstance();
|
||||
*/
|
||||
export declare class Singleton {
|
||||
protected constructor();
|
||||
static GetInstance<T extends Singleton>(this: ConstructorType<T, typeof Singleton>): T;
|
||||
}
|
||||
//# sourceMappingURL=Singleton.d.ts.map
|
Reference in New Issue
Block a user