Created
January 16, 2019 10:26
-
-
Save tswistak/03b2afacd8bdb42422336f1e3a8e6a4e to your computer and use it in GitHub Desktop.
Avoiding any in TypeScript, listing 3
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
| const dict2: { a?: string } & Record<string, number> = {}; | |
| dict2.a = 'a'; | |
| dict2.a = 1; // ERROR: 1 is not assignable to type string | |
| dict2.b = 2; | |
| dict2.b = 'b'; // ERROR: "b" is not assignable to type number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment