Created
January 27, 2019 07:02
-
-
Save CreatiCoding/613458a4219f267f160d90b7617d3d81 to your computer and use it in GitHub Desktop.
TypeScript - intersection types simple 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
| // From https://gist.github.com/Ibro/262ee343ea3a2a244ec76b44f6723713#file-typescript-intersection-type-simple-ts | |
| // Origin code is error code. So I fix it by referencing https://www.typescriptlang.org/docs/handbook/interfaces.html | |
| interface IStudent { | |
| id: string; | |
| age: number; | |
| } | |
| interface IWorker { | |
| companyId: string; | |
| } | |
| let x = <IStudent & IWorker>{}; | |
| x.age = 5; | |
| x.companyId = "CID5241"; | |
| x.id = "ID3241"; | |
| console.log(x); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
result