Skip to content

Instantly share code, notes, and snippets.

@jwcarroll
Created July 31, 2016 01:11
Show Gist options
  • Save jwcarroll/0269420ba05a1a72e9fb238a330656df to your computer and use it in GitHub Desktop.
Save jwcarroll/0269420ba05a1a72e9fb238a330656df to your computer and use it in GitHub Desktop.
TypeScript constructor overloading
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