Skip to content

Instantly share code, notes, and snippets.

@thebeebs
Created February 12, 2014 22:09
Show Gist options
  • Save thebeebs/8965565 to your computer and use it in GitHub Desktop.
Save thebeebs/8965565 to your computer and use it in GitHub Desktop.
You can add an interface to an object so the miss spelling of clear() is picked up and the app will not compile.
interface Rapper {
say(x: string): void;
clear(): void;
speak(): string;
}
function makeRapper(): Rapper{
var words;
return {
say: function (x: string){
words = x;
},
clearSpeltWrong: function (){
words = '';
},
speak: function(){
return words;
}
};
}
makeRapper();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment