Skip to content

ES6 spread syntax does not properly compile when targeting ES3/ES5 #12010

@aaronlahey

Description

@aaronlahey

TypeScript Version: 2.1.0-dev.20161102

Code

Source

export class Foo {
  public foo(...strings: string[]): this {
    return this;
  }
}

const instance = new Foo();

instance
  .foo(...[])
  .foo(...[])

Compiled Code

"use strict";
var Foo = (function () {
    function Foo() {
    }
    Foo.prototype.foo = function () {
        var strings = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            strings[_i - 0] = arguments[_i];
        }
        return this;
    };
    return Foo;
}());
exports.Foo = Foo;
var instance = new Foo();
(_a = instance
    .foo(...[])).foo.apply(_a, []);
var _a;

Expected behavior:

The compiled code should not contain ....

Actual behavior:

(_a = instance
    .foo(...[])).foo.apply(_a, []);

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: TransformsRelates to the public transform APIFixedA PR has been merged for this issueHigh Priority

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions