Annotated solution
Published September 16, 2026The solution
type FromEntries<T extends [PropertyKey, unknown]> = { [K in T[0]]: Extract<T, [K, unknown]>[1] }The common wrong answer
type FromEntries<T extends [PropertyKey, unknown]> = { [K in T[0]]: T[1] }The keys are right and every value is wrong. T is still the whole union inside the mapping, so T[1] is every value at once: { a: 1 | 2; b: 1 | 2 }. Iterating over T[0] narrows the *key* you are writing, not the T you are reading from.
Line by line
Extract<T, [K, unknown]>This is the re-narrowing step. For each
Kit pulls out only the pairs whose first element is that key, discarding the rest of the union.FromEntries<['a', 1] | ['a', 2]>Two pairs share a key, so the extraction keeps both and the value really is
1 | 2. A union here is correct — the earlier one was correct too, just attached to the wrong keys.
Takeaway
Iterating over a union does not narrow the union itself, only the key you are producing. If you need the matching member back, Extract is how you ask for it.

