Created
July 3, 2016 05:19
-
-
Save myuon/cdbd59ee0da4c878def6254932c9245d to your computer and use it in GitHub Desktop.
typescript: extending interface
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
| import * as $ from "jquery"; | |
| function extend<T extends U, U>(itrf: T, part: U): T { | |
| return $.extend(itrf, part); | |
| } | |
| // -------- | |
| interface Test { | |
| poyo: string, | |
| nyan: number | |
| }; | |
| let u: Test = {poyo: "piyo", nyan: 20}; | |
| let u2: Test = extend(u, {poyo: "hey"}); | |
| // Error | |
| // let u3: Test = extend(u, {noname: "hey"}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment