Skip to content

Probably improper error message when dealing with spread operator #5189

Closed
@barcicki

Description

@barcicki

Consider following example:

console.log(...['Hello', 'world']);

It's a completely valid console.log usage scenario however TypeScript (@1.6.2) raises TS2346 error: Supplied parameters do not match any signature of call target.

The log's signature is:

declare function log(message?: any, ...optionalParams: any[]);

Therefore following code:

console.log('Hello', ...['world']);

is considered valid, without any errors.

In my opinion the top example should not trigger any errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions