List Which Fields Changed, Typed
Write the code, see it run, pass the checks.
The problem
- easy
- Code
Write changedKeys(before, after): given two versions of the same record, return the names of the fields whose values differ, compared with Object.is (no deep comparison), in before's key order. Type it so after must have the same type as before (a value of another shape is a type error), and so the result is an array of the record's own keys, which can then read either object without casts.
Your code must pass
- Lists the fields that changed, in order
- Compares with Object.is
- Has no type errors
- Returns the record's keys
- Rejects a different shape for after