diff --git a/dist/utils.d.ts b/dist/utils.d.ts index c091007..c17cb2c 100644 --- a/dist/utils.d.ts +++ b/dist/utils.d.ts @@ -14,7 +14,11 @@ interface DescriptorWithOwner extends PropertyDescriptor { export declare function getInheritedDescriptor(obj: T, key: keyof T): DescriptorWithOwner | undefined; export declare function getInheritedPropertyNames(obj: T): (keyof T)[]; export type Constructor = (new (...a: A) => T) & Static; -export declare function Constructor(Ctor: Constructor): Constructor & Static; +export declare function Constructor(Ctor: AnyConstructor): Constructor & Static; +export type AbstractConstructor = (abstract new (...a: A) => T) & Static; +export declare function AbstractConstructor(Ctor: AnyConstructor): AbstractConstructor & Static; +export type AnyConstructor = Constructor | AbstractConstructor; +export declare function AnyConstructor(Ctor: AnyConstructor): AnyConstructor & Static; export declare function hasPrototype(obj: any, proto: any): boolean; export declare function copyDescriptors(source: Object, destination: Object, mod?: any): void; export declare function setDefaultPrototypeDescriptors(prototype: Object, { defaultClassDescriptor: { writable, enumerable, configurable } }: any): void; diff --git a/dist/utils.d.ts.map b/dist/utils.d.ts.map index e058798..e4f7650 100644 --- a/dist/utils.d.ts.map +++ b/dist/utils.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IACzB,CAAC,wBAAgB;IACjB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAIxB,GAAG,CAAC,IAAI,EAAE,MAAM;IAGhB,GAAG,CAAC,IAAI,EAAE,MAAM;CAGhB;AAGD,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAKpD;AAQD,wBAAgB,aAAa,CAAC,CAAC,SAAS,EAAE,EACzC,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,MAAM,CAAC,EACZ,aAAa,EAAE,kBAAkB,EACjC,SAAS,UAAQ,GACf,IAAI,CAKN;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,M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AAK,EAAE,GAAG,WAShD;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,QAS7E;AAED,wBAAgB,8BAA8B,CAC7C,SAAS,EAAE,MAAM,EACjB,EAAC,sBAAsB,EAAE,EAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAC,EAAC,EAAE,GAAG,QAmBnE;AAED,wBAAgB,2BAA2B,CAC1C,IAAI,EAAE,GAAG,EACT,EAAC,sBAAsB,EAAE,EAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAC,EAAC,EAAE,GAAG,EACnE,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,QAwBrC"} \ No newline at end of file diff --git a/dist/utils.js b/dist/utils.js index f392ae3..3f362ee 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -94,6 +94,12 @@ export function getInheritedPropertyNames(obj) { export function Constructor(Ctor) { return Ctor; } +export function AbstractConstructor(Ctor) { + return Ctor; +} +export function AnyConstructor(Ctor) { + return Ctor; +} export function hasPrototype(obj, proto) { let currentProto = obj.__proto__; do { diff --git a/dist/utils.js.map b/dist/utils.js.map index d8cd781..192ec0f 100644 --- a/dist/utils.js.map +++ b/dist/utils.js.map @@ -1 +1 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACzB,CAAC,GAAG,IAAI,OAAO,EAAE,CAAA;IACjB,GAAG,CAAC,CAAS,EAAE,CAAS;QACvB,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAChB,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,GAAG,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;I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CAAA;YACvB,SAAQ;SACR;QAED,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA;QAG7B,IAAI,OAAO,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,EAAE;YACtD,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAA;SAC9B;QAGD,UAAU,CAAC,UAAU,GAAG,UAAU,CAAA;QAClC,UAAU,CAAC,YAAY,GAAG,YAAY,CAAA;KACtC;IAED,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;AAClC,CAAC"} \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 02a835b..40eb33f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -135,13 +135,77 @@ export function getInheritedPropertyNames(obj: T): (keyof T)[] return keys } +/** + * Without type args, this is an easy shortcut for "any non-abstract constructor + * that has any args and returns any type of object". + * + * With type args, define a non-abstract constructor type that returns a certain + * instance type (optional), accepts certain args (optional, defaults to any + * args for simplicity in cases like class-factory mixins), and has certain + * static members (optional). + */ export type Constructor = (new (...a: A) => T) & Static -// this is used for type casting in special cases, see the declaration file -export function Constructor(Ctor: Constructor): Constructor & Static { +/** + * Cast any constructor type (abstract or not) into a specific Constructor type. + * Useful for forcing type checks inside of mixins for example. This is unsafe: + * you can incorrectly cast one constructor into an unrelated constructor type, + * so use with care. + */ +export function Constructor(Ctor: AnyConstructor): Constructor & Static { return Ctor as unknown as Constructor & Static } +/** + * Without type args, this is an easy shortcut for "any abstract constructor + * that has any args and returns any type of object". + * + * With type args, define an abstract constructor type that returns a certain + * instance type (optional), accepts certain args (optional, defaults to any + * args for simplicity in cases like class-factory mixins), and has certain + * static members (optional). + */ +export type AbstractConstructor = (abstract new (...a: A) => T) & + Static + +/** + * Cast any constructor type (abstract or not) into a specific + * AbstractConstructor type. Useful for forcing type checks inside of mixins + * for example. This is unsafe: you can incorrectly cast one constructor into an + * unrelated constructor type, so use with care. + */ +export function AbstractConstructor( + Ctor: AnyConstructor, +): AbstractConstructor & Static { + return Ctor as unknown as AbstractConstructor & Static +} + +/** + * Combines Constructor and AbstractConstructor to support assigning any type of + * constructor whether abstract or not. + * + * Without type args, this is an easy shortcut for "any constructor, abstract or not, + * that has any args and returns any type of object". + * + * With type args, define a constructor type (abstract or not) that returns a + * certain instance type (optional), accepts certain args (optional, defaults to + * any args for simplicity in cases like class-factory mixins), and has certain + * static members (optional). + */ +export type AnyConstructor = + | Constructor + | AbstractConstructor + +/** + * Cast any constructor type (abstract or not) into a specific + * AnyConstructor type. Useful for forcing type checks inside of mixins + * for example. This is unsafe: you can incorrectly cast one constructor into an + * unrelated constructor type, so use with care. + */ +export function AnyConstructor(Ctor: AnyConstructor): AnyConstructor & Static { + return Ctor as unknown as AnyConstructor & Static +} + // check if an object has the given prototype in its chain export function hasPrototype(obj: any, proto: any) { let currentProto = obj.__proto__