Skip to content

Instantly share code, notes, and snippets.

@dherman
Created October 1, 2012 16:25
Show Gist options
  • Save dherman/3812823 to your computer and use it in GitHub Desktop.
Save dherman/3812823 to your computer and use it in GitHub Desktop.
TypeScript type system examples
// This type-checks and compiles.
function Thing(arg : string) { }
var obj = new Thing("");
if (true) {
obj.x = 3;
}
obj.x.send();
// This fails with a type error.
function Thing(arg : string) { }
var obj = new Thing(42);
if (true) {
obj.x = 3;
}
obj.x.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment