Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/decorate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<object, Set<string>>();

Expand Down
14 changes: 14 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T = object> = {
new (...args: unknown[]): T,
prototype: T,
};

export interface Integration {
/**
* Defines a reactive property on an object.
Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* allowing you to build complex objects from simpler pieces.
*/

import type { Constructor } from '@/interfaces';

type AnyObject = Record<string, unknown>;

type OptionalPropertyNames<T> = {
Expand Down Expand Up @@ -94,8 +96,6 @@ export function merge<A extends ObjectOrFactory[]>(...types: [...A]): Spread<A>
return newVal as Spread<A>;
}

type Constructor = new (...args: unknown[]) => object;

/**
* Applies mixin classes to a base class by merging their prototypes.
*
Expand Down
Loading