Created
November 18, 2019 11:32
-
-
Save 1amageek/11772955c992195e4825733832a73fae to your computer and use it in GitHub Desktop.
Animal.ts
This file contains 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 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