Created
January 4, 2018 21:52
-
-
Save jwalsh/ab42cbb8dc4be30e36471b3678609fad to your computer and use it in GitHub Desktop.
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
| let u1: number | string | boolean = 1; | |
| console.log(u1); | |
| let u2 = 1 | 2; | |
| console.log(u2); | |
| // The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. | |
| // let u3 = 'A' | 'B'; | |
| interface A { | |
| message: string; | |
| } | |
| interface B { | |
| message: string; | |
| } | |
| // No error | |
| let u4: A | B = { | |
| message: "Test" | |
| }; | |
| console.log(u4); | |
| // error TS2322: Type '{ error: string; }' is not assignable to type 'A | B'.let u5: A | B = { | |
| error: "Test" | |
| }; | |
| console.log(u5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment