Learn / macOS

Learn TypeScript with lessons and practice

Use TypeScript worked examples, drills, and linked challenges to turn a language concept into a skill.

TypeScript lessons with the lesson catalog, worked examples, and drills.
TypeScript lessons with the lesson catalog, worked examples, and drills. Select the image to enlarge.
  1. Choose a concept

    Choose an available lesson on narrowing, generic types, tuples, or conditional types. Identify the input type and the result you want.

    Example

    Given a result union with kind: success or kind: failure, state which fields are safe to use inside each branch.

  2. Trace and explain

    Complete the lesson drill and explain why an assignment or expression should type-check. Revisit prerequisites if you cannot justify the rule.

    Example

    For a generic first-element helper, predict the difference between an empty array and a fixed nonempty tuple.

  3. Apply it in practice

    Open a related type challenge and preserve the starter’s assertions. Use the available type checks and inspect the first diagnostic.

    Example

    For a mapped-type exercise, check whether optional and readonly modifiers are preserved as the contract requires.

Check your work

You can explain a worked example and use the same rule on a new input or exercise.

Try it yourself

Design a union with kind: loading, kind: success, and kind: failure. Give only the success branch a value and only the failure branch a message. In a type exercise, narrow by kind before using either field.

What to look for
The loading branch permits neither field. A direct access without narrowing should fail if the field is absent from any member of the union.