Classes in TypeScript Explained
TypeScript classes build on JavaScript's class syntax with type annotations for fields, constructors, and methods. Learn the basics of writing typed classes from scratch.
Type-safe JavaScript with TypeScript
TypeScript classes build on JavaScript's class syntax with type annotations for fields, constructors, and methods. Learn the basics of writing typed classes from scratch.
TypeScript constructors initialize new class instances. Learn how to type constructor parameters, use default values, write overloaded constructors, and handle the this context safely.
TypeScript access modifiers control which parts of your code can see and use class members. Learn the differences between public, private, and protected, and when to use each.
The readonly modifier prevents reassignment to a class property after the constructor finishes. Learn how to use it, when it helps, and how it differs from const.
The implements keyword tells TypeScript that a class must satisfy a specific interface. Learn how it checks your class shape without changing its type or runtime behavior.
Abstract classes define a contract that subclasses must fulfill. Learn how to use the abstract keyword to create base classes that cannot be instantiated directly.
Inheritance shares behavior through parent classes. Composition builds objects by combining smaller pieces. Learn when each pattern works best in TypeScript.
Parameter properties let you declare and initialize class fields directly in the constructor signature. Learn this TypeScript shorthand that eliminates repetitive boilerplate.
TypeScript decorators are functions that modify classes, methods, properties, and parameters at design time. Learn the different decorator types and how to use them.
Learn how to design TypeScript classes that model real-world concepts like users, orders, and products. Practical patterns for building maintainable domain models.
Default exports let a TypeScript module export a single main value. Learn how they work, when to use them, and the tradeoffs compared to named exports.
Common mistakes with conditional types, infer, distributive behavior, recursive types, and branded types -- and how to fix each one.