Skip to content

Instantly share code, notes, and snippets.

@cocodrino
Created April 16, 2021 13:59
Show Gist options
  • Save cocodrino/0147819a07186fd45eb78d674344b03e to your computer and use it in GitHub Desktop.
Save cocodrino/0147819a07186fd45eb78d674344b03e to your computer and use it in GitHub Desktop.
factory typescript
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