TS7034
error TS7034: Variable ‘
expectations
‘ implicitly has type ‘any[]
‘ in some locations where its type cannot be determined.
Broken Code ❌
1 |
|
Fixed Code ✔️
An array can collect values of different types, so we have to tell TypeScript which types we want to collect:
1 |
|
If we want to specify multiple types, we have to define a union type:
1 |
|
Alternative:
1 |
|
Unrecommended solutions:
- Set “noImplicitAny” to
false
in your “tsconfig.json”