Function Overloads in TypeScript
Function overloads let a single function accept different argument counts and types. Learn overload signatures, the implementation signature, and when to use a union instead.
Type-safe JavaScript with TypeScript
Function overloads let a single function accept different argument counts and types. Learn overload signatures, the implementation signature, and when to use a union instead.
An object type describes the shape of a JavaScript object by listing its properties and their expected types. Learn how to write object types, what the compiler checks, and how they catch common bugs.
Optional properties let you mark object properties as not required. Add a question mark after the property name, and TypeScript knows the value might be undefined. Learn the syntax and safe patterns.
Readonly marks TypeScript object properties as immutable at compile time. Add the modifier before a property name, and TypeScript prevents reassignment. Learn the syntax and its limits.
A TypeScript type alias is a name you give to any type. Use the type keyword to create reusable names for object shapes, unions, and tuples, and learn when to choose one over an interface.
Interfaces and type aliases both name object shapes in TypeScript, but they differ in merging, extension style, and what they can describe. Learn the key differences and when to choose each.
Excess property checks catch unknown properties on object literals passed directly to typed positions. Learn when this check fires, when it does not, and how to handle it correctly.
An index signature lets you type objects when you do not know the exact property names ahead of time, only the pattern of keys and values. Learn the syntax and when to use it.
Declaration merging lets you declare the same interface multiple times in the same scope. TypeScript combines them into one. Learn how merging works, where it is useful, and its rules.
Apply object types, interfaces, optional properties, and readonly to model a real dataset: a library of books. Build types step by step and see how the compiler guides correct data shapes.
TypeScript uses the instanceof operator to narrow union types containing classes. Learn how it works with built-in types like Date and Error, custom classes, and the prototype chain.
A tsconfig.json file tells TypeScript how to compile your project. Learn how to create one, what the key sections mean, and which options to set first.