Skip to content

Typescript parsed spread operator in function call problem #28486

@gilbertoalbino

Description

@gilbertoalbino

I have a piece of code as is:

function add(a: number, b: number, c: number) {
  return a + b + c;
}

const hexagons = [1, 6, 15];

const result = add(...hexagons);

And VS Code complains about:
[ts] Expected 3 arguments, but got 0 or more.

I haven't found if it is necessary to set some config option or this is a bug in the VSCode TS parser itself.

But it is valid code in Chrome:

function add(a, b, c) {
  return a + b + c;
}
const hexagons = [1, 6, 15];
const result = add(...hexagons);

So I think VSCode is wrongly parsing TS.

Metadata

Metadata

Assignees

Labels

DuplicateAn existing issue was already createdIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions