Created
July 31, 2016 01:11
-
-
Save jwcarroll/0269420ba05a1a72e9fb238a330656df to your computer and use it in GitHub Desktop.
TypeScript constructor overloading
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 Foo { | |
constructor(id:number); | |
constructor(name:string); | |
constructor(public id:string|number){} | |
getId(){ | |
return this.id; // id: string|number | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment