Last active
October 27, 2016 11:02
-
-
Save gonta/3755a1d6ceacc80e59c00342ff649bea to your computer and use it in GitHub Desktop.
Typescriptで、Object[key]とすると出るIndex signature of object type implicitly has an 'any' type.を正しく回避する ref: http://qiita.com/gonta/items/fb7b9e6d0f12060c27d6
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 pokemon { | |
| PIKACHU: boolean, | |
| RAICHU: boolean, | |
| YADORAN: boolean | |
| \[key: string]: boolean | |
| } | |
| let key: string = 'PIKACHU'; | |
| let pikachu: string = pokemon[key]; |
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
| Property 'PIDHION' of type 'number' is not assignable to string index type 'boolean'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment