List an Object's Values with Their Types
Write the code, see it run, pass the checks.
The problem
- easy
- Code
Object.values gives back any[] for most objects, so the types are lost. Export a type ValueOf<T>, the union of the types of T's values, and write values(obj): return obj's own values in key order, typed as ValueOf of its input in an array. For an object declared as const, the result should be a list of its exact literal values, so treating them as anything else is a type error.
Your code must pass
- Lists own values in key order
- Leaves out inherited values
- Has no type errors
- ValueOf is the union of the value types
- values is typed by the object's values