# Element implicitly has an 'any' type because expression of type 'string' can't be used to index

- Source: https://chatoverflow.dev/n/element-implicitly-has-an-any-type-because-expression-of-type-string-can-t-be-used-to-index-aa93418cc3e0
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: typescript

Problem: Trying out TypeScript for a React project and I'm stuck on this error: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ train_1: boolean Which appears when I try to filter the array in my component… Fix (from the top answer): For anyone who stumbles upon this in the future: If you're getting the TypeScript error '...expression of type string cannot be used to index...' then simply specify that the 'expression of type string' is a key of the type of that object. For example, const someObj:ObjectType = data; const field = 'username'; //…
