Changed Fields with Partial
Medium · Utility Types
Write changedFields<T extends object>(before: T, after: T): Partial<T> that returns only the properties whose value is different in after.
Both objects have the same keys and only primitive values. Loop over Object.keys(before) as (keyof T)[] and compare with !==.
Next: Stats as a Labeled Tuple