Last active
September 15, 2017 21:49
-
-
Save russleyshaw/f287be9b260d93649cd7ede5077839da to your computer and use it in GitHub Desktop.
Allow generic extended construction.
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
interface FooConstructor<T> { | |
new(val: number): T; | |
} | |
interface FooInterface { | |
myVal: number; | |
} | |
class Foo implements FooInterface { | |
myVal: number; | |
constructor(val: number) { | |
this.myVal = val; | |
} | |
doFoo() { } | |
} | |
class Bar<T extends FooInterface> { | |
public doot: T; | |
constructor(ctor: FooConstructor<T>) { | |
this.doot = new ctor(4); | |
} | |
} | |
const f = new Bar(Foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment