Skip to content

Spread operator in method shorthand in object literal is not emitted with "__assign"  #17087

Closed
@kobiburnley

Description

@kobiburnley

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)

Link to playground

Code

const y = {
  prop: "ms"
}

const x = {
  ...y,
  fn(options) {
    return {
      timestamps: false,
      ...options
    }
  }
}

Emits to:

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;
};
var y = {
    prop: "ms"
};
var x = __assign({}, y, { fn: function (options) {
        return {
            timestamps: false,
            ...options
        };
    } });

Expected behavior:
"...options" will be emitted with "__assign"
Actual behavior:
"...options" is not emitted with "__assign"

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions