Skip to content

Instantly share code, notes, and snippets.

Created October 2, 2012 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3818003 to your computer and use it in GitHub Desktop.
Save anonymous/3818003 to your computer and use it in GitHub Desktop.
TypeScript implements keyword
interface IGreeter {
greeting: string;
greet() : string;
}
class Greeter implements IGreeter{
greeting: string;
constructor (message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
var greeter = new Greeter("world");
var button = document.createElement('button')
button.innerText = "Say Hello"
button.onclick = function() {
alert(greeter.greet())
}
document.body.appendChild(button)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment