Loading lesson path
TypeScript
Understand TypeScript syntax, types, narrowing, interfaces, generics, and practical usage patterns.
TypeScript Tutorial
TypeScript is JavaScript with added syntax for types. What is TypeScript? TypeScript is a syntactic superset of JavaScript which adds static typing. This basically means that TypeScript adds syntax o…
TypeScript Compiler TypeScript is transpiled into JavaScript using a compiler. TypeScript being converted into JavaScript means it runs anywhere that JavaScript runs! Installing the Compiler TypeScri…
TypeScript enhances JavaScript by adding static types. JavaScript and TypeScript Primitives The most basic types in TypeScript are called primitives. These types form the building blocks of more comp…
Type Annotations and Inference TypeScript offers two ways to work with types: Explicit Typing : You explicitly declare the type of a variable Type Inference : TypeScript automatically determines the…
TypeScript includes several special types that have specific behaviors in the type system. These types are used in various scenarios to handle cases where the type might not be known in advance or wh…
Typed Arrays A tuple is a typed array with a pre-defined length and types for each index. Tuples are great because they allow each element in the array to be a known type of value. To define a tuple,…
An enum is a special "class" that represents a group of constants (unchangeable variables). Enums come in two flavors string and numeric. Let's start with numeric. Numeric Enums - Default By default,…
TypeScript allows types to be defined separately from the variables that use them. Aliases and Interfaces allows types to be easily shared between different variables/objects. Type Aliases Type Alias…
TypeScript has a specific syntax for typing function parameters and return values. Read more about functions here. Return Type The type of the value returned by the function can be explicitly defined…
There are times when working with types where it's necessary to override the type of a variable, such as when incorrect types are provided by a library. Casting is the process of overriding a type. C…
TypeScript adds types and visibility modifiers to JavaScript classes. Learn more about JavaScript classes here. Members: Types The members of a class (properties & methods) are typed using type annot…
Generics allow creating 'type variables' which can be used to create classes, functions & type aliases that don't need to explicitly define the types that they use. Generics make it easier to write r…
TypeScript comes with a large number of types that can help with some common type manipulation, usually referred to as utility types. This chapter covers the most popular utility types. Partial Parti…
keyof is a keyword in TypeScript which is used to extract the key type from an object type. keyof with explicit keys When used on an object type with explicit keys, keyof creates a union type with th…
TypeScript has a powerful system to deal with null or undefined values. By default null and undefined handling is disabled, and can be enabled by setting strictNullChecks to true. The rest of this pa…
NPM packages in the broad JavaScript ecosystem don't always have types available. Sometimes the projects are no longer maintained, and other times they aren't interested in, agree with, or have time…
TypeScript is actively maintained and updated by Microsoft. In version 5.x a lot of utility and quality of life updates were made. This chapter covers the most popular updates to allow stricter and m…
Introduction The tsconfig.json file is the heart of every TypeScript project. It tells the TypeScript compiler how to process your code, which files to include, and which features to enable or disabl…
TypeScript with Node.js
TypeScript Development Ecosystem TypeScript's tooling ecosystem is one of its greatest strengths, providing developers with powerful tools for every stage of development: Code Quality ESLint with Typ…
Advanced TypeScript Types TypeScript's advanced type system allows you to model complex type relationships with precision. These features are particularly useful for building robust, maintainable app…
Understanding Type Guards in TypeScript TypeScript Type Guards are powerful constructs that allow you to narrow down the type of a variable within a specific scope. They help TypeScript understand an…
Understanding Conditional Types in TypeScript Conditional types in TypeScript enable you to create types that depend on other types, similar to how if-else statements work in JavaScript. They're a po…
Mapped types in TypeScript allow you to create new types by transforming properties of existing types. Mapped types = transform every property of a type Common ones: Partial, Readonly, Pick, Omit, Re…
Understanding Literal Types in TypeScript Literal types in TypeScript allow you to specify exact values that variables can hold, providing more precision than broader types like string or number. The…
Understanding TypeScript Namespaces TypeScript namespaces (previously known as "internal modules") provide a powerful way to organize code and prevent naming conflicts by creating a container for rel…
Understanding Index Signatures in TypeScript Index signatures in TypeScript provide a powerful way to define types for objects with dynamic property names while maintaining type safety. They allow yo…
Understanding Declaration Merging Declaration merging is a powerful TypeScript feature that allows you to combine multiple declarations with the same name into a single definition. This enables you t…
Master asynchronous programming in TypeScript with Promises, async/await, error handling, and advanced patterns. Learn best practices for writing robust async code.
Decorators are a powerful TypeScript feature that allow you to add metadata and modify classes and their members at design time. They are widely used in frameworks like Angular and NestJS for depende…
TypeScript in JavaScript Projects (JSDoc)
Migrating from JavaScript to TypeScript can significantly improve your codebase's maintainability and developer experience. This guide will walk you through the process step by step. Preparation Phas…
Robust error handling is crucial for building reliable TypeScript applications. This guide covers everything from basic try/catch to advanced error handling patterns. Basic Error Handling Try/Catch B…
This guide covers essential TypeScript best practices to help you write clean, maintainable, and type-safe code. Following these practices will improve code quality and developer experience. Project…