Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aaronlahey opened this issue Nov 2, 2016 · 0 comments · Fixed by #12039
Closed

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

aaronlahey opened this issue Nov 2, 2016 · 0 comments · Fixed by #12039
Assignees
Labels
Bug A bug in TypeScript Domain: Transforms Relates to the public transform API Fixed A PR has been merged for this issue High Priority

Comments

@aaronlahey
Copy link

aaronlahey commented Nov 2, 2016

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, []);
@mhegazy mhegazy added Bug A bug in TypeScript High Priority labels Nov 3, 2016
@mhegazy mhegazy added this to the TypeScript 2.1.2 milestone Nov 3, 2016
@mhegazy mhegazy added the Domain: Transforms Relates to the public transform API label Nov 3, 2016
@aaronlahey aaronlahey added the Fixed A PR has been merged for this issue label Nov 7, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Transforms Relates to the public transform API Fixed A PR has been merged for this issue High Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants