Skip to content
webtype.orgwebtype.org#263 from-entries · par 3

    ↑↓ move · ⏎ open · esc close

    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.ts
    Stroke 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

    3
    • FromEntries<['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 characters

    No public scores yet.

    Archive