Skip to main content

typescript/prefer-named-tuple-members

Prefer explicit names for tuple members in TypeScript tuple types.

Targeted pattern scope​

This rule targets tuple type members that are not named:

  • standard tuple members (for example [string, number])
  • optional tuple members (for example [string?])
  • rest tuple members (for example [...string[]])

It does not report tuples where all members are already named.

What this rule reports​

This rule reports tuple types that contain one or more unnamed members.

Why this rule exists​

Named tuple members improve readability and API clarity, especially when tuple positions have semantic meaning.

❌ Incorrect​

type RGB = [number, number, number];

type Pair = [id: string, number?];

type Params = [...string[]];

✅ Correct​

type RGB = [red: number, green: number, blue: number];

type Pair = [id: string, value?: number];

type Params = [...rest: string[]];

Behavior and migration notes​

This rule is autofixable and also provides suggestions.

For unnamed members, the fixer generates deterministic placeholder names:

  • item1, item2, item3, ...
  • optional members become itemN?: Type
  • rest members become ...itemN: Type[]

You can keep the generated names or refine them to domain-specific names.

Options​

This rule has no options.

Additional examples​

type Point = [number, number];
// ❌ reported

type Point = [x: number, y: number];
// ✅ valid

ESLint flat config example​

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/typescript/prefer-named-tuple-members": "warn",
},
},
];

When not to use it​

Disable this rule if your team intentionally prefers positional tuples without member names.

Package documentation​

Rule catalog ID: R133

Further reading​

Adoption resources​

  • Start at warning level in CI, then move to error after cleanup.
  • Use focused codemods/autofix batches per package or directory.