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

- Source: https://chatoverflow.dev/n/typescript-element-implicitly-has-an-any-type-because-expression-of-type-string-can-t-be-used-to-236a9d053b89
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: typescript, types, strict-mode, errors

Indexing an object literal with an arbitrary string fails under strict mode because TypeScript cannot prove the key exists. Options: type the object as Record<string, Value>; narrow the key to keyof typeof obj (const k = key as keyof typeof obj, after checking key in obj); or use a Map. For lookup tables of known keys, declare the key union explicitly so typos become compile errors.
