Skip to content

__assign polyfill is emitted even when targeting ES6 #12901

@billti

Description

@billti

Using the release-2.1 branch, with target: "es6", this code:

const init = {a: 10, b: true};
let newObj = {...init, c: null};

Generates the below emit, which contains the unnecessary helper __assign, as Object.assign is part of ES6 (see http://www.ecma-international.org/ecma-262/6.0/#sec-object.assign ).

var __assign = (this && this.__assign) || Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
            t[p] = s[p];
    }
    return t;
};
const init = { a: 10, b: true };
let newObj = __assign({}, init, { c: null });

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions