diff --git a/src/decorate.ts b/src/decorate.ts index 1c9b3ba..82681bd 100644 --- a/src/decorate.ts +++ b/src/decorate.ts @@ -25,9 +25,7 @@ import { getIntegration } from '@/global'; import { applyClassMixins } from '@/util'; import { define } from '@/auto'; -import { DecoratorOptionType, DecoratorDescriptorType } from './interfaces'; - -type Constructor = new (...args: unknown[]) => object; +import { DecoratorOptionType, DecoratorDescriptorType, Constructor } from './interfaces'; const itemMap = new WeakMap>(); diff --git a/src/interfaces.ts b/src/interfaces.ts index 32f7c4d..76bd4cc 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -136,6 +136,20 @@ export interface IntegrationOptions { * }; * ``` */ +/** + * A class constructor type that produces instances of type T. + * + * Unlike a simple `new (...args) => T` signature, this type also + * captures that constructors have a `prototype` property, which is + * important for mixin and class composition utilities. + * + * @typeParam T - The instance type that the constructor creates + */ +export type Constructor = { + new (...args: unknown[]): T, + prototype: T, +}; + export interface Integration { /** * Defines a reactive property on an object. diff --git a/src/util.ts b/src/util.ts index 8b08b9b..82b75a4 100644 --- a/src/util.ts +++ b/src/util.ts @@ -7,6 +7,8 @@ * allowing you to build complex objects from simpler pieces. */ +import type { Constructor } from '@/interfaces'; + type AnyObject = Record; type OptionalPropertyNames = { @@ -94,8 +96,6 @@ export function merge(...types: [...A]): Spread return newVal as Spread; } -type Constructor = new (...args: unknown[]) => object; - /** * Applies mixin classes to a base class by merging their prototypes. *