Skip to content
loading...

re: Advanced TypeScript Exercises - Answer 2 VIEW POST

FULL DISCUSSION
 

But admin should have type Admin.

Argument of the function is type T and so is the return type. In your example is the type of argument Admin, therefor is the return type also Admin.

 

Type is Admin but the structure which is returned has kind property with value customer, so its not valid member of the type Admin.

 

Yes, it's not valid. But admin should always be type of Admin, or an error should occur (like in this case).

code of conduct - report abuse