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[]) {}
Related: TS1048