• Error
  • Reported by the lexer and parser

TS1013

A rest parameter or binding pattern may not have a trailing comma.

A rest parameter (`...args`) or rest element in a destructuring pattern is followed by a comma. Remove the comma after it.

What it means

A rest parameter or rest element collects everything that's left, so nothing may follow it, not even a trailing comma. This applies to function parameters (...args,) and to array and object destructuring patterns ([first, ...rest,]).

Example

index.ts
function log(...messages: string[],) {}
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,35): error TS1013: A rest parameter or binding pattern may not have a trailing comma.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Delete the comma after the rest parameter or rest element.
  • If you meant to add another parameter, it has to come before the rest parameter.