/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * @module utils/mix */ /** * Helper type that represents constructor creating given objects. Can be used as a type constraint. * * ```ts * // The function accepts any class constructor. * function MyFunction( ctor: Ctor ) { * // ... * } * * // The function accepts any class constructor of type derived from `MyBase`. * function MyFunction>( ctor: Ctor ) { * // ... * } * ``` */ export type Constructor = abstract new (...args: Array) => Instance; /** * Helper type that creates constructor types from a base class and a mixin interface. * * ```ts * interface MyMixinInterface { * mixinMethod(): void; * } * * function MyMixin( base: Base ): Mixed { * // ... * } * * class BaseClass { * baseMethod(): void { * // ... * } * } * * const MixedClass = MyMixin( BaseClass ); * * // Contains both `mixinMethod()` and `baseMethod()`. * const myObject = new MixedClass(); * myObject.mixinMethod(); * myObject.baseMethod(); * ``` * * @typeParam Base A type of constructor of a class to apply mixin to. * @typeParam Mixin An interface representing mixin. */ export type Mixed = { new (...args: ConstructorParameters): Mixin & InstanceType; prototype: Mixin & InstanceType; } & { [K in keyof Base]: Base[K]; };