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

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type