ProjectStack
typescript

TS2556: A spread argument must either have a tuple type or be passed to a rest parameter

You're spreading an array into a function call, but TypeScript can't verify that the array's contents match the function's parameters. Spreading works safely when the array is a tuple (fixed length and types) or the function accepts rest parameters.

Common causes

  • Spreading a general array (string[], number[]) into a function that expects specific individual arguments
  • Dynamically building an argument list as an array and spreading it into a typed function
  • The spread value is typed as an array and the function has a specific, fixed signature
  • Using apply() alternatives with spread where the argument types can't be verified

How to fix it

  1. Type the array as a tuple: const args: [string, number] = ['hello', 42]; fn(...args)
  2. Use as const to make the array a tuple: const args = ['hello', 42] as const
  3. Change the function to accept rest parameters: function fn(...args: [string, number])
  4. Pass arguments individually rather than spreading if the list is short

Example

function add(a: number, b: number): number { return a + b; } const args = [1, 2]; add(...args); // error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter.

Spreading a number[] array into a function — TypeScript can't verify the element count or types match

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.