Skip to content

Instantly share code, notes, and snippets.

@1amageek
Created November 18, 2019 11:32
Show Gist options
  • Save 1amageek/11772955c992195e4825733832a73fae to your computer and use it in GitHub Desktop.
Save 1amageek/11772955c992195e4825733832a73fae to your computer and use it in GitHub Desktop.
Animal.ts
class Animal<T> {
static identity<T extends new (...args: any[]) => Animal<any>>(this: T) {
return this;
}
static create<T extends Animal<any>>(this: new (...args: any[]) => T) {
return new this();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment