Skip to content

Instantly share code, notes, and snippets.

@gonta
Last active October 27, 2016 11:02
Show Gist options
  • Select an option

  • Save gonta/3755a1d6ceacc80e59c00342ff649bea to your computer and use it in GitHub Desktop.

Select an option

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
interface pokemon {
PIKACHU: boolean,
RAICHU: boolean,
YADORAN: boolean
\[key: string]: boolean
}
let key: string = 'PIKACHU';
let pikachu: string = pokemon[key];
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