error TS2361: The right-hand side of an ‘in’ expression must not be a primitive.
Broken Code ❌
Fixed Code ✔️
You cannot use the
in keyword on primitive data types. That’s why we have to replace the primitive type
unknown with a non-primitive type like
An alternative solution would be to use a type assertion on the right-hand side of the ‘in’ expression: