Created
February 14, 2024 22:28
-
-
Save iliocatallo/98e90d083e6214c97cba18479b781e34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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