Skip to content
Learn Netverks

Lesson

Step 21/32 66% through track

type-narrowing

Type narrowing

Last reviewed May 28, 2026 Content v20260528
Track mode
client_typescript
Means
In-browser TS
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Type narrowing—the ideas, syntax, and habits you need before moving on in TypeScript.

Narrowing and unions model real-world data shapes and eliminate whole classes of runtime bugs.

You will apply Type narrowing in contexts like: Modern front-end apps, Node APIs, and any team that standardizes on TS-first tooling.

Write TypeScript, compile in the browser, run the emitted JavaScript, and check understanding with MCQs.

When the previous lesson's MCQs feel easy and you can explain Type narrowing in your own words.

Control flow refines types: typeof, instanceof, equality checks, and user-defined type predicates (value is string).

Discriminant-free narrowing

Truthy checks narrow nullable types. in operator narrows union members with shared fields. Control-flow analysis follows return and throw too.

Self-check

  1. Narrow string | number with typeof in an if/else.

Editor tooling uses the same control-flow graph to autocomplete properties only valid in the current branch.

Practice: Apply type-narrowing in the playground, then explain type narrowing in one sentence without looking at notes.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What part of this lesson needs a second read?
  • What would you try differently in a real project?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump