TSConfig
suppressImplicitAnyIndexErrors
Turning suppressImplicitAnyIndexErrors
on suppresses reporting the error about implicit anys when indexing into objects, as shown in the following example:
tsTry
constobj = {x : 10 };Element implicitly has an 'any' type because expression of type '"foo"' can't be used to index type '{ x: number; }'. Property 'foo' does not exist on type '{ x: number; }'.7053Element implicitly has an 'any' type because expression of type '"foo"' can't be used to index type '{ x: number; }'. Property 'foo' does not exist on type '{ x: number; }'.console .log (obj ["foo"]);
Using suppressImplicitAnyIndexErrors
is quite a drastic approach. It is recommended to use a @ts-ignore
comment instead:
tsTry
constobj = {x : 10 };// @ts-ignoreconsole .log (obj ["foo"]);