Skip to content

Instantly share code, notes, and snippets.

@iliocatallo
Created February 14, 2024 22:28
Show Gist options
  • Select an option

  • Save iliocatallo/98e90d083e6214c97cba18479b781e34 to your computer and use it in GitHub Desktop.

Select an option

Save iliocatallo/98e90d083e6214c97cba18479b781e34 to your computer and use it in GitHub Desktop.
interface Role {
m1(): boolean;
m2(): number;
}
interface RoleConstructor<Ts extends unknown[]> {
new (...params: Ts): Role
}
class Concretion implements Role {
private readonly arg1: string
constructor(arg1: string) {
this.arg1 = arg1;
}
m1(): boolean {
return true;
}
m2(): number {
return 42;
}
}
class RoleFromFile {
private readonly RolePlayer: RoleConstructor<[arg1: string]>;
constructor(RolePlayer: RoleConstructor<[string]>) {
this.RolePlayer = RolePlayer;
}
build() {
return new this.RolePlayer("test");
}
}
const roleFromFile = new RoleFromFile(Concretion)
const test = roleFromFile.build();
console.log(test);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment