Skip to content
webtype.org#235 pick-by-type · par 3

No. 235 · August 18, 2026 · Moderate

PickByType

Implement `PickByType<T, U>` so it keeps only the properties whose value type is assignable to `U`. The rejected keys must disappear entirely, not survive as `never`.

01

Puzzle

Par 3

Puzzle

pick-by-type.ts
interface Mixed {
  id: number
  name: string
  active: boolean
  score: number
}
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

4
  • PickByType<Mixed, number>
    { id: number; score: number }
  • PickByType<Mixed, string>
    { name: string }
  • PickByType<Mixed, symbol>
    {}
  • PickByType<{ a: string }, string>
    { a: string }

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.

Archive
02

Annotated solution

This write-up publishes 24 hours after the puzzle closes.