Learnr

Learn TypeScript

Add types to the JavaScript you know and catch bugs before they run.

or browse all courses.

Free to start. Built from a single prompt. No credit card.

TypeScript is JavaScript with a static type system layered on top, developed by Microsoft. You write .ts files with annotations like string, number and custom interfaces, and the compiler checks them before turning your code into plain JavaScript that runs anywhere JavaScript does. The types disappear at runtime, so their value is catching mistakes early and making editors smarter with autocomplete and safe renames. It is now common in React, Node.js and Angular projects. Learnr builds a personalized TypeScript course from your prompt and teaches it through short, interactive lessons.

How to learn TypeScript, step by step

  1. Know JavaScript well before adding types. TypeScript adds no new runtime behavior, so confusion about closures, promises or this in JavaScript stays confusing with types on top. Be comfortable with modern JavaScript first, especially objects, arrays and async functions.
  2. Experiment in the TypeScript Playground. Use the official online Playground to write small snippets and see both the type errors and the compiled JavaScript side by side. Hover over variables to see what type the compiler inferred.
  3. Let inference do most of the work. Annotate function parameters and public return types, but let TypeScript infer local variables. Learn the difference between any, which switches checking off, and unknown, which forces you to check before use.
  4. Model data with interfaces and unions. Describe API responses with interfaces, optional properties and readonly fields. Use discriminated unions, such as a status field of loading, success or error, and narrow them with if or switch statements.
  5. Learn generics through real functions. Write a generic function like first<T>(items: T[]) and a typed wrapper around fetch. Then explore utility types such as Partial, Pick, Omit and Record, which you will see constantly in codebases.
  6. Convert a small JavaScript project. Install TypeScript with npm, run tsc --init, turn on strict, and rename files one at a time to .ts. Fixing the errors teaches more than any tutorial; short daily Learnr lessons help the type syntax stick.

What you'll learn

  • Annotate variables, functions and return values with precise types
  • Describe data shapes with interfaces and type aliases
  • Model alternatives with union types and narrow them safely
  • Write reusable, type-safe code with generics
  • Configure tsconfig.json and adopt strict mode in a real project

What's inside your TypeScript course

A sample path Learnr builds for TypeScript. Your real course adapts to your goal and level.

  • 1. Why TypeScript exists and how compilation works
  • 2. Basic types, inference and function signatures
  • 3. Interfaces, type aliases and object shapes
  • 4. Unions, literal types and type narrowing
  • 5. Generics and built-in utility types
  • 6. TypeScript in a real project with React or Node.js

How long does it take to learn TypeScript?

If you already know JavaScript, the everyday features take 2 to 4 weeks at a few hours a week. Advanced types like conditional and mapped types take a few more months of real project use. Without JavaScript, learn that first, which adds 2 to 4 months.

What you need before you start

Solid JavaScript, including functions, objects, arrays, modules and promises. Node.js and npm installed, and an editor such as Visual Studio Code that shows type errors inline.

Common mistakes to avoid

  • Sprinkling any everywhere to silence errors, which removes the checking you came for. Use unknown and narrow it, or write the proper type.
  • Assuming types validate data at runtime. JSON from an API is not checked, so validate external data before trusting the type you gave it.
  • Leaving strict mode off in a new project. Turn on strict from the start, since enabling it later means fixing hundreds of errors at once.

How Learnr builds your course

Type your topic

Tell Learnr you want to learn TypeScript, or get as specific as you like.

Get a personalized course

Learnr instantly builds a full TypeScript course tailored to your goal and skill level.

Learn and level up

Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.

TypeScript questions, answered

Should I learn JavaScript or TypeScript first?

JavaScript first. TypeScript is a layer on top of it, and every TypeScript program becomes JavaScript before it runs. A few months of JavaScript makes TypeScript quick to pick up.

Does TypeScript make code run faster?

No. Types are removed during compilation, so the output runs like ordinary JavaScript. The benefit is fewer bugs, clearer code and better editor tooling, not speed.

Can I use TypeScript with React?

Yes. Tools like Vite and Next.js have TypeScript templates, and you type props with interfaces and state with generics such as useState<string>().

Explore more courses

More programming and tech courses

See all programming and tech courses

Ready to learn TypeScript?

Start your free, personalized TypeScript course in seconds. .