Skip to content
webtype.orgwebtype.orgTwelve concepts

    ↑↓ move · ⏎ open · esc close

    Twelve concepts

    Twelve lessons with runnable exercises, from type aliases to recursive conditional types. Start at the beginning or pick a concept to practise.

    0 of 12 exercises completed

    Continue learning: Type aliases

    Exercise progress is saved on this device.

    1. 01

      Type aliases

      A name for a type. Everything else here is an alias that takes arguments.

      Read the lesson
    2. 02

      Generic parameters

      Aliases take arguments. `extends` in this position is a constraint, not inheritance.

      Read the lesson
    3. 03

      keyof and indexed access

      `keyof T` is the union of T’s keys; `T[K]` reads a property type back out.

      Read the lesson
    4. 04

      Mapped types

      Build an object by iterating a union of keys: `{ [K in Keys]: Value }`.

      Read the lesson

      Practiced in#212 Rebuild Pick#219 Rebuild Partial#226 Rebuild Readonly#235 PickByType#236 Getters#241 Rebuild Required#242 Merge#246 Entries#247 Omit by type#249 Optional, but only these#256 Invert#257 Tuple to object#258 Which keys are optional

    5. 05

      Modifiers

      Add or strip `readonly` and `?` while mapping, with `+` and `-`.

      Read the lesson

      Practiced in#212 Rebuild Pick#219 Rebuild Partial#226 Rebuild Readonly#235 PickByType#236 Getters#241 Rebuild Required#242 Merge#246 Entries#247 Omit by type#249 Optional, but only these#256 Invert#257 Tuple to object#258 Which keys are optional

    6. 06

      Conditional types

      `A extends B ? X : Y` — the type-level `if`, asking about assignability.

      Read the lesson

      Practiced in#220 Rebuild Exclude#230 Permutation#238 UnionToIntersection#248 Is it never?

    7. 07

      infer

      Bind a type variable inside a pattern and use it in the true branch.

      Read the lesson

      Practiced in#213 Unwrap#221 Return Type

    8. 08

      Distributivity

      A naked type parameter in a conditional distributes over unions. `[T]` stops it.

      Read the lesson

      Practiced in#220 Rebuild Exclude#230 Permutation#238 UnionToIntersection#248 Is it never?

    9. 09

      Template literal types

      String patterns at the type level. Combined with `infer`, they parse.

      Read the lesson

      Practiced in#214 Route Params#217 Split#224 Join#225 Trim#228 Replace#231 CamelCase#233 StartsWith#243 Absolute#244 Repeat#252 Query string#253 Snake case

    10. 10

      Recursion

      A conditional type that calls itself. The false branch is the exit.

      Read the lesson

      Practiced in#215 Deep Readonly#222 Reverse#227 Includes#229 Flatten#237 Unique#240 Filter#245 Paths#251 Optional all the way down#259 Get by path

    11. 11

      Variadic tuples

      Spread tuples into tuples. `length` turns them into a counter.

      Read the lesson

      Practiced in#216 Type-level Add#218 Last#223 Type-level Subtract#232 Zip#234 TupleToUnion#239 Chunk#250 Fill#254 Without#255 First

    12. 12

      Exact equality

      Why `Equal<X, Y>` is not `extends`, and why an intersection fails it.

      Read the lesson