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

vllm : Failed to infer device type

android studio kotlin source is null error

gemini cli getting file not defined error