TS7031
error TS7031: Binding element ‘age’ implicitly has an ‘any’ type.
Broken Code ❌
1 |
|
Fixed Code ✔️
TypeScript complains because it doesn’t know the type of the argument that we are destructuring. That’s why it sets all its properties to the type of any
. To prevent that we have to define a type for the parameter of the printAge
function:
1 |
|