Backend development

Stage 1 · Lesson 3 of 10

TypeScript types and strict mode

Your language and how HTTP works

adds static types to . You say what kind of value each thing holds, and TypeScript checks it before the code runs. Learn the basic types first: strings, numbers and booleans.

Then learn interfaces and type aliases, which describe the shape of an object. Union types list the allowed values, such as 'admin' | 'member'. Also learn optional fields and like Promise<User>, which is a that will hold a User.

Narrowing with typeof and in lets TypeScript work out which type you have. Turn on strict in tsconfig.json from the first file, so null and undefined must be handled on purpose. Types make changes safer and editors more helpful, which matters more as a service grows.

Common trapbelieving types protect you while the program runs. They are erased when the code is compiled, so a request body typed as User is still unchecked JSON. It stays unchecked until you validate it, which you will do with a library in the API stage.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    JavaScript itself in a sensible order: scope, closures, promises and async code

  • GuideFree
    Node.js Learn

    OpenJS Foundation · Beginner

    Official guides on the event loop, async work, the http module and environment variables

Practise

  • Your language track: small exercises with free mentor feedback on idiomatic code

Keep handy

  • Read Everyday Types and Narrowing first, then keep it open while you write TypeScript

  • Read the HTTP overview, methods, headers and status code pages until they feel obvious

Also worth your time

Mark this stage as not done?