Created
April 21, 2015 23:00
-
-
Save tmlbl/cf6b5a342041dba51db9 to your computer and use it in GitHub Desktop.
Typed Class
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 Typed<T> { | |
type: T | |
constructor(obj: T) { | |
this.type = obj; | |
} | |
} | |
interface MyType { | |
prop: string; | |
} | |
var instance = new Typed<MyType>({ prop: 'foo' }); | |
console.log(instance.type.prop); // foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment