Annotated solution
Published August 30, 2026The solution
type ObjectEntries<T> = { [K in keyof T]: [K, T[K]] }[keyof T]
The common wrong answer
type ObjectEntries<T> = [keyof T, T[keyof T]]
This produces a single pair whose halves are both unions: `["a" | "b", string | number]`. That type permits `["a", number]` — a key paired with the wrong value — because the correlation between key and value was lost the moment both were collapsed to unions independently.
Line by line
{ [K in keyof T]: [K, T[K]] }Inside the mapping, `K` is one specific key at a time, so `T[K]` is that key’s own value type. The pairing is built while the correlation still exists.
[keyof T]Only now is everything collapsed into a union — and by this point each pair is already sealed, so no key can drift onto another key’s value.
Takeaway
Distribute first, collapse last. Once two related things have been turned into separate unions their relationship is gone, and no amount of later work can pair them back up correctly.

