Skip to content
webtype.orgwebtype.org

    ↑↓ move · ⏎ open · esc close

    No. 278 · September 30, 2026 · Moderate

    Camelize the keys

    Implement CamelKeys<T> so string keys written in snake_case become camelCase. Values and non-string keys stay untouched.

    01

    Puzzle

    Par 3

    Puzzle

    camelize-keys.ts
    type CamelKey<S extends string> =
      S extends `${infer H}_${infer R}` ? `${H}${Capitalize<CamelKey<R>>}` : S
    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
    • CamelKeys<{ first_name: string; user_id: number }>—
      → { firstName: string; userId: number }
    • CamelKeys<{ plain: true; two_words_here: 1 }>—
      → { plain: true; twoWordsHere: 1 }
    • CamelKeys<{ 0: 'zero'; snake_key: 'x' }>—
      → { 0: 'zero'; snakeKey: 'x' }

    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
    02

    Annotated solution

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

    Uses