No. 263 · Moderate · mapped types
From entries
Implement `FromEntries<T>` so a union of `[key, value]` pairs becomes an object. Each key must end up with its own value, not everybody’s.
Puzzle
from-entries.tsStroke 1 of 3Not run yet
Replace ??? — your solution is checked against the cases below. Tab indents; press Escape then Tab to move focus out.
Checks
3FromEntries<['a', 1] | ['b', 2]>—→ { a: 1; b: 2 }FromEntries<['x', string]>—→ { x: string }FromEntries<['a', 1] | ['a', 2]>—→ { a: 1 | 2 }
How a check is judged Exact type equality, not assignability — an intersection is not the same as the flattened object.
How everyone did
Fewer than 5 people have solved this one so far. The distribution appears once there is enough of a sample to mean anything.
Short game
Fewest charactersNo public scores yet.

