Skip to content

Excess spread arguments are not errored #19900

@kitsonk

Description

@kitsonk

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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions