the tswhy logo: a question mark in a box

tswhy‽

A community effort to enrich TypeScript diagnostics.

TS1047

A rest parameter cannot be optional.

Marking a parameter optional (?) indicates that it could be undefined, but when using the rest token (...) indicates that if there are no additional arguments being passed, parameter will simply be set to an empty array. Therefore these tokens are incompatible:

function test(...args?: any[]) {}

Fix: Remove optional token.

Remove the ? token:

function test(...args: any[]) {}