String Number and Boolean Types in TypeScript
TypeScript's string, number, and boolean types map directly to JavaScript primitives. Learn how to use each one, what values they accept, and common mistakes to avoid.
Type-safe JavaScript with TypeScript
TypeScript's string, number, and boolean types map directly to JavaScript primitives. Learn how to use each one, what values they accept, and common mistakes to avoid.
An enum is a way to define a set of named constants in TypeScript. Learn numeric enums, string enums, const enums, and when to use enums versus union types.
New TypeScript developers make the same mistakes: skipping parameter types, overusing any, and forgetting that types disappear at runtime. Learn to spot and fix the most frequent errors.
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.
A literal type is a type that represents exactly one value. Learn how string, number, and boolean literal types work, why they matter with union types, and when to use const assertions.
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.
Readonly values in TypeScript prevent accidental mutation. Learn readonly properties, ReadonlyArray, readonly tuples, the Readonly utility type, and how readonly differs from const.
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 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.
TypeScript types disappear at runtime, and the most common mistakes happen when developers forget this. Learn the pitfalls of typeof, instanceof, type assertions, and structural checking so you stop trusting types at runtime.