TS7017
error TS7017: Element implicitly has an ‘
any
‘ type because type ‘{}
‘ has no index signature.
Broken Code ❌
1 |
|
Fixed Code ✔️
You have to define the type for indexing your object properties (object["index"]
):
1 |
|
The name of the index can be freely chosen:
1 |
|
How to fix such errors in interfaces:
1 |
|
Alternative, but not recommend:
- Set “noImplicitAny” to
false
in your “tsconfig.json”
error TS7017: Element implicitly has an ‘
any
‘ type because type ‘typeof globalThis
‘ has no index signature.
Broken Code ❌
1 |
|
Fixed Code ✔️
1 |
|
Reference: