Skip to content

Spread operator is not correctly translated into JS #8856

Closed
@tnikodym

Description

@tnikodym

TypeScript Version: 1.8
Target: ES5

The following code:

[...(new Array(5))]

translates into:

(new Array(5)).slice();

However, the ES6 meaning is not the same. See the output below:

> [...(new Array(5))]
[ undefined, undefined, undefined, undefined, undefined ]
> (new Array(5)).slice();
[ , , , ,  ]

Expected behavior:

Array.apply(null, Array(5))

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptES6Relates to the ES6 Spec

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions