TS2352
error TS2352: Conversion of type ‘
{ name: string; age: number; }
‘ to type ‘Person
‘ may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to ‘unknown
‘ first.
Broken Code ❌
1 |
|
Fixed Code ✔️
Make sure all properties of your object match the properties of your declared type:
1 |
|
Alternative but not recommended: Convert your object to unknown
first:
1 |
|