Skip to content

Instantly share code, notes, and snippets.

@logentries-gists
Created February 17, 2016 21:13
Show Gist options
  • Select an option

  • Save logentries-gists/47c2544a3aa909395357 to your computer and use it in GitHub Desktop.

Select an option

Save logentries-gists/47c2544a3aa909395357 to your computer and use it in GitHub Desktop.
interface TeamColours {
colour: “red” | “blue” | “white”;
}
class Team {
constructor(colours: TeamColours){
this.colours = colours;
}
}
new Team({ colour: “Black” }) // Error: Type ‘”Black”’ is not assignable to type ‘“red” | “blue” | “white”’
new Team({ colour: “blue” }); // Works, colour is allowed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment