Let and Const in TypeScript
TypeScript infers different types for let and const. Learn how block scoping changes type inference, why const gets literal types, and when to choose each.
Type-safe JavaScript with TypeScript
TypeScript infers different types for let and const. Learn how block scoping changes type inference, why const gets literal types, and when to choose each.
Type widening is how TypeScript expands a narrow inferred type into a wider, more general one. Learn when widening happens, why let widens but const does not, and how to control it.
Type narrowing is how TypeScript refines a wide union type to a more specific one based on runtime checks. Learn typeof, truthiness, equality, and in-operator narrowing.
TypeScript uses structural typing to decide if one type can be assigned to another. Learn the rules of assignment compatibility for objects, functions, and primitives.
TypeScript can infer types in many places, but some spots always need annotations. Learn when inference is enough and when you must write types explicitly.
A function type describes what arguments a function accepts and what it returns. Learn the arrow syntax for function types, how to use type aliases, and where function types appear in real code.
Every function parameter in TypeScript needs a type annotation. Learn the syntax for typing parameters, why inference does not work here, and how to handle destructured parameters.
Mark a function parameter as optional with the ? syntax. Learn how optional parameters work, how they interact with undefined, and the key rule for callbacks.
A rest parameter collects any number of remaining arguments into a typed array. Learn the ... syntax, how to type rest parameters, and the difference between rest parameters and spread arguments.
Arrow functions in TypeScript can be typed just like regular functions. Learn the syntax for typing arrow function parameters, return types, and how contextual typing works differently.
A callback is a function passed as an argument to another function. Learn how to type callback parameters and the key rule about optional callback parameters.
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.