Skip to content

Type Alias: CallableNewable<ClassConstructorOptions, C>

ts
type CallableNewable<ClassConstructorOptions, C> = {
(...args: ConstructorParameters<C>): InstanceType<C>;
  schema: ObjectSchema<ClassConstructorOptions>;
} & (...args: ConstructorParameters<C>) => InstanceType<C> & {
  prototype: InstanceType<C>;
};

A hybrid type that represents a constructor function which can be called both with and without the new keyword. This type enables creating data type classes that work as both constructors and factory functions.

Type Declaration

NameType
prototypeInstanceType<C>

Type Parameters

Type ParameterDefault typeDescription
ClassConstructorOptions extends BaseInterface-The interface defining the constructor options for the class
C extends BaseClassBaseClassThe abstract constructor type constraint