Function mixin

  • Function to mixin multiple classes together and create a new class, which can be extended from.

    The first entry of the mixin() call will be used as base class.

    Example


    class Timestampable {
    createdAt: Date = new Date;
    updatedAt: Date = new Date;
    }

    class SoftDeleted {
    deletedAt?: Date;
    deletedBy?: string;
    }

    class User extends mixin(Timestampable, SoftDeleted) {
    id: number = 0;
    constructor(public username: string) {}
    }

    Type Parameters

    • T extends AbstractClassType<any>[]

    Parameters

    • Rest ...classTypes: T

    Returns ClassType<UnionToIntersection<ExtractClassType<T[number]>>>

Generated using TypeDoc