Answers for "typescript element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{"

11

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'.ts(7053)

//This will fail typecheck
const map = {};
map[someString] = "hello";

//This will pass typecheck
const map: {[key:string]: string} = {};
map[someString] = "hello";
Posted by: Guest on June-24-2021
0

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

tsconfig.json

 "compilerOptions": {
   	...
    "noImplicitReturns": true,
    "noImplicitAny": false,
    ...
 }
Posted by: Guest on November-09-2021

Code answers related to "typescript element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{"

Code answers related to "Javascript"

Browse Popular Code Answers by Language