Created
February 12, 2014 22:09
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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