Created
April 16, 2021 13:59
-
-
Save cocodrino/0147819a07186fd45eb78d674344b03e to your computer and use it in GitHub Desktop.
factory typescript
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
class Person { | |
firstName = 'John'; | |
lastName = 'Doe'; | |
} | |
class Factory { | |
create<T>(type: (new () => T)): T { | |
return new type(); | |
} | |
} | |
let factory = new Factory(); | |
let person = factory.create(Person); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment