Last active
February 6, 2019 21:05
-
-
Save LFSCamargo/9d2ffb76d7c05989c3edd900fb9b484f to your computer and use it in GitHub Desktop.
Interface composition example
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 User { | |
username: string; | |
email: string; | |
password: string; | |
} | |
// So here we cant user the & operator after extends to compose types | |
// So if you want to extend more than one interface or type you need to use type | |
interface Compose extends User { | |
example: Object; | |
users: User[]; | |
} | |
/** | |
How this will look like on the end: | |
{ | |
example: {}, | |
username: 'foo', | |
email: '[email protected]', | |
password: '123', | |
users: [...], | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment