Named Tuples

What

Named tuples allow you to add descriptive labels to each element in the tuple definition.

How

You add a label followed by a colon before the type of each element:

type UserData = [name: string, age: number, isAdmin: boolean];

function getUser(): UserData {
  return ["Frodo", 33, false];
}

Why

Labels make your code self-documenting. When you hover over a variable or function that uses a named tuple, your editor will show the labels, making it clear what each position represents without you needing to jump to the type definition.

Summary

While labels are purely for documentation and don’t change how data is accessed, they significantly improve the developer experience by making positional data clearer.