01Chapter 1: Typing arrays with T[] and Array<T>This chapter assumes basic JavaScript arrays and array methods, TypeScript type annotations, and union types such as string | number. You should know how to declare variables and call methods such as map, filter, and reduce.1 min read
02Chapter 2: How TypeScript infers array literal typesTypeScript can infer an array type from the values in an array literal. This chapter assumes that you know basic JavaScript arrays, TypeScript annotations, and union types.2 min read
03Chapter 3: Reading elements and noUncheckedIndexedAccessThis chapter assumes that you know JavaScript arrays, TypeScript annotations, and union types. The focus is reading an element by index and handling the possibility that no element exists.2 min read
04Chapter 4: Typing array methods and filtering with type guardsAssume you know basic JavaScript arrays, TypeScript annotations, and union types. This chapter focuses on how TypeScript tracks element types through common array methods, especially filter.2 min read
05Chapter 5: Readonly arraysAssume you know JavaScript arrays, basic TypeScript annotations, and union types. This chapter focuses on preventing a function from mutating an array through the reference it receives.2 min read
06Chapter 6: Tuples: fixed length, typed positionsAssume you know basic JavaScript arrays, TypeScript annotations, and union types. This chapter focuses on tuple types: arrays whose length and position types are known in advance.1 min read
07Chapter 7: When to use a tuple and when to use an arrayAssume you know basic JavaScript arrays, TypeScript annotations, and union types. This chapter focuses on choosing between an array, which holds a variable-length sequence of similar values, and a tuple, which describes a fixed structure with a known type at each position.2 min read
08Chapter 8: Destructuring tuples and returning multiple valuesThis chapter assumes basic JavaScript arrays, destructuring, TypeScript annotations, and union types. You will use tuple types to describe a fixed sequence of values, then unpack those values with destructuring.2 min read
09Chapter 9: Optional and rest elements in tuplesThis chapter assumes basic JavaScript arrays, TypeScript annotations, and union types. It also assumes you know that a tuple records the type of each position, while an array records one element type for any number of positions.2 min read
10Chapter 10: Labeled tuple elementsThis chapter assumes you know basic TypeScript annotations, union types, arrays, and tuple types. A tuple is an array whose length and position types are known.2 min read
11Chapter 11: Readonly tuples and as constPrerequisites: you should know basic TypeScript annotations, union types, arrays, and ordinary tuples. This chapter focuses on preserving exact tuple positions while preventing mutation through a particular reference.2 min read
12Chapter 12: Tuple pitfalls: push and out-of-range accessAssume you know JavaScript arrays, basic TypeScript annotations, and union types. This chapter focuses on two surprising behaviors: mutable tuples can grow with push, and tuple indexing depends on whether the index is known at compile time.2 min read
13Chapter 13: Tuples as function parameter listsAssume you know basic TypeScript function types, tuple syntax, optional and rest parameters, and union types. In TypeScript, a tuple can describe a function's complete parameter list. This lets you store arguments in a variable, pass them with spread syntax, and transform parameter lists in generic 2 min read
14Chapter 14: Variadic tuple typesThis chapter assumes basic JavaScript arrays, TypeScript annotations, and union types. You should already know that a tuple stores values with a fixed length and a type for each position.2 min read