TypeScript Version: 2.6.1
Code
It appears that extra arguments that are spread arguments are always accepted, which can lead to unintentional errors in the code. For example the following:
declare const foo: (value: string) => string;
foo('bar', 'qat'); // Expected 1 arguments, but got 2.
foo('bar', ...['qat']); // No error
This is related to #4130 but @sandersn suggested a separate issue, as this subset of the larger issue is likely addressable, where as determining if a spread argument might result in longer arguments is difficult, versus cases where it is easily statically identifiable (this case).
Expected behavior:
That an extra spread argument errors.
Actual behavior:
An excess spread argument does not error.
TypeScript Version: 2.6.1
Code
It appears that extra arguments that are spread arguments are always accepted, which can lead to unintentional errors in the code. For example the following:
This is related to #4130 but @sandersn suggested a separate issue, as this subset of the larger issue is likely addressable, where as determining if a spread argument might result in longer arguments is difficult, versus cases where it is easily statically identifiable (this case).
Expected behavior:
That an extra spread argument errors.
Actual behavior:
An excess spread argument does not error.