Typescript mixin and how to use it.



Declaring mixin in typescript




type Constructor<T = {}> = new (...args: any[]) => T;

function Handler<BaseType extends Constructor>(TargetType: BaseType) {
return class extends TargetType {
isActivated = false;
};
}

class User {
name = ""
}

const i = Handler(User);
const idec = new i



Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm