Created
May 23, 2016 20:58
-
-
Save abner/7fbd33ac4ee292514b1191ef3441faa1 to your computer and use it in GitHub Desktop.
Typescript - Runtime Methods
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 MusicKeyboard { | |
| playC(): string; | |
| } | |
| function addMusicKeyboardMethods(object: Object): MusicKeyboard { | |
| Object.defineProperties(object, { | |
| "playC": function() { | |
| return "Playing C on Keyboard"; | |
| } | |
| }); | |
| return <MusicKeyboard>object; | |
| } | |
| let a: Object = {}; | |
| let aWrappedAsMusicKeyboard: MusicKeyboard = addMusicKeyboardMethods(a); | |
| aWrappedAsMusicKeyboard.playC(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment