TS2411
error TS2411: Property ‘age’ of type ‘number’ is not assignable to ‘string’ index type ‘string’.
Broken Code ❌
1 |
|
Fixed Code ✔️
We defined an interface where every key
has a value of type string
. This doesn’t work for age
which is why we have to extend the possible value types using a union type:
1 |
|