Interactive roadmap
TypeScript roadmap
Designed for JavaScript developers who want to write safer code, this roadmap helps you catch bugs early and build robust applications with confidence.
- 1
Why Types Matter
0 of 3 done
Understand the core benefits of adding types to your everyday JavaScript workflow.
Take it one step at a time and let your code editor guide you. - 2
Objects and Shapes
0 of 3 done
Define the structure of complex data using interfaces and type aliases.
Clear object shapes make your data structures much easier to manage. - 3
Combining and Narrowing Types
0 of 3 done
Handle values that can be one of several different types gracefully.
Combine flexibility with safety by narrowing down types when needed. - 4
Generics and Utilities
0 of 3 done
Write flexible, reusable code without losing the safety of strict types.
Use generics to write flexible code without losing type safety. - 5
Using with Frameworks
0 of 3 done
Apply your TypeScript skills to real web applications and component libraries.
Leverage community types to integrate older libraries smoothly.
Learn it all, with a tutor that never sleeps
Every topic links to LevelUp lessons, practice exercises and the 24/7 AI Tutor. Your progress updates as you master lessons.
Every topic explained
Step 1: Why Types Matter
- TypeScript adds helpful rules to JavaScript, catching silly mistakes before your code even runs in the browser.TypeScript Documentation
Read more
TypeScript is a programming language built on top of JavaScript. It adds an optional safety net by checking your code for errors before it ever runs in the browser. Think of it like spellcheck for your code, spotting missing commas or mismatched words as you type.
Imagine filling out an online form where the box turns red if you type a letter into a phone number field. TypeScript does something similar for developers, stopping common silly mistakes early.
This matters because catching bugs early saves hours of frustration later, helping you write reliable code with confidence.
- Built on top of standard JavaScript
- Catches common errors before code runs
- Improves your code editor autocomplete suggestions
- Learn how to label strings, numbers, and booleans so your editor can keep you on track.
Read more
Basic data types are the fundamental labels you attach to values in your code. They tell TypeScript whether a piece of data is text, a number, or a simple yes-or-no switch.
For example, when saving a user score, you label that variable as a number. If you accidentally try to assign a sentence to that score later, your editor flags it immediately.
Using basic types keeps your data consistent across your entire application, preventing unexpected bugs from sneaking into your logic.
- Strings handle text values
- Numbers handle integers and decimals
- Booleans represent true or false flags
- (optional)
- Use tsconfig json files to control how TypeScript checks your project and outputs clean JavaScript.
Read more
The TypeScript compiler turns your TypeScript files into standard JavaScript that browsers can understand. A configuration file lets you control how strict these checks should be.
Think of it like setting the house rules for a renovation project, deciding which safety standards to enforce and where the final output files should go.
Configuring this properly ensures your entire team follows the same rules and keeps your build process running smoothly.
- Uses a file named tsconfig json
- Controls strictness of type checking
- Sets input and output folders
Step 2: Objects and Shapes
- Tell TypeScript what properties an object should have and which ones are optional.
Read more
Objects hold collections of related data, like a user profile containing a name and an age. Object types let you define the exact shape this data must take.
If you are building a shopping app, you might specify that every product object needs a title string and a price number, while a discount code is optional.
This matters because it stops you from accidentally trying to read properties that do not exist on your data.
- Define required and optional properties
- Prevent missing property errors
- Describe nested data structures clearly
- Create reusable blueprints for your data structures to keep your code neat and organised.
Read more
Interfaces and type aliases are reusable blueprints for your data structures. Instead of typing out object shapes repeatedly, you define them once and use them everywhere.
Think of this like an architectural blueprint used to build multiple houses on a street, ensuring every building follows the exact same floor plan.
Using these blueprints keeps your codebase neat, organised, and easy to update when requirements change.
- Interfaces are great for object shapes
- Type aliases can handle unions too
- Make code DRY and reusable
- Manage lists of items and fixed length collections with specific data types inside them.
Read more
Arrays and tuples help you manage lists of items. While standard arrays hold many items of the same type, tuples let you store a fixed number of items with different specific types.
Imagine a shopping list where every item is text, compared to a geographic coordinate that is always stored as a pair of numbers in a specific order.
Mastering these structures ensures your collections stay predictable and safe to loop through.
- Arrays hold lists of a single type
- Tuples enforce fixed length and types
- Improve safety when handling ordered data
Step 3: Combining and Narrowing Types
- Allow a variable or function argument to accept multiple different types of data.
Read more
Union types let a variable accept more than one type of data. You use a vertical bar to combine possibilities, giving your functions extra flexibility.
For example, an ID field might accept either a number or a string depending on where the data came from.
This allows you to work with messy real-world data sources while still keeping TypeScript informed about the possible values.
- Combine types using the pipe symbol
- Accept multiple inputs safely
- Handle flexible data sources
- Use simple checks like typeof to prove to TypeScript which specific type you are working with.
Read more
Type narrowing is the process of taking a broad union type and figuring out its exact type at runtime using simple conditional checks.
Think of checking an incoming parcel to see if it fits through the letterbox before deciding how to handle delivery.
This matters because it lets you safely use methods specific to strings or numbers after you have proven what the data actually is.
- Use typeof checks in conditions
- Prove exact types to TypeScript
- Unlock specific methods safely
- (optional)
- Restrict a variable to hold only one exact specific value, like a specific status string.
Read more
Literal types restrict a variable to hold only one exact specific value, rather than just any string or number.
For instance, an order status might be restricted to only allow pending, shipped, or delivered, preventing typos like shpped.
This is vital for state management, ensuring invalid states are impossible to represent in your code.
- Lock values to exact strings or numbers
- Prevent invalid state typos
- Great for configuration options
Step 4: Generics and Utilities
- Create components and functions that can work with any data type while remembering what you passed in.
Read more
Generics let you write reusable components that work with any data type while still remembering the specific type you passed in.
Think of a storage box with a label slot on the front. The box can hold anything, but the label tells you what is inside.
This is essential for building flexible utilities, data stores, and UI components that need to handle different data shapes across your app.
- Write flexible reusable functions
- Preserve exact types through operations
- Avoid using vague fallback types
- Use built-in helpers to transform existing types, such as making all properties optional instantly.
Read more
Utility types are built-in helpers provided by TypeScript to transform existing types into new ones without rewriting code.
For example, if you have a strict user profile type, you can use a utility to create a new version where every property becomes optional for update forms.
These shortcuts save time and keep your type definitions DRY and maintainable.
- Transform existing types easily
- Make all properties optional instantly
- Pick or omit specific fields
- (optional)
- Understand when to escape strict type checking and why unknown is much safer than any.
Read more
The any type turns off type checking entirely, which can be risky. The unknown type is a much safer alternative for values you do not recognise yet.
Imagine finding an unmarked mystery box. any lets you open it blindly, while unknown forces you to check what is inside before using it.
Knowing when to use unknown helps you handle unpredictable data from APIs safely.
- Avoid any to keep safety checks active
- Use unknown for unpredictable data
- Inspect unknown data before use
Step 5: Using with Frameworks
- Correctly label function parameters, return values, and browser click events.
Read more
Typing functions involves explicitly stating what parameters a function expects and what data it returns.
Think of a recipe that lists exact ingredients needed and confirms the final dish produced at the end.
This ensures that other parts of your app call your functions correctly and catch mistakes before runtime.
- Define parameter and return types
- Type browser event listeners
- Prevent incorrect function arguments
- See how popular tools like React or Node integrate TypeScript out of the box.
Read more
Modern frameworks like React and Node support TypeScript out of the box, combining type safety with your favourite development tools.
This is like upgrading your car with built-in navigation and parking sensors, making your journey much smoother.
Setting this up correctly helps you build robust applications faster with instant feedback from your editor.
- Supported natively in modern frameworks
- Improves component and API design
- Streamlines build and run processes
- (optional)
- Install community type definitions when using older JavaScript libraries in your project.
Read more
Many older JavaScript libraries do not include type definitions by default. You can install community definitions to add type support to them.
Think of it as putting instruction labels in English on a tool imported from abroad.
This matters because it lets you use the entire JavaScript ecosystem without losing your TypeScript safety net.
- Use DefinitelyTyped community packages
- Install types via package manager
- Unlock autocomplete for older libraries