Skip to content

Support computed properties downlevel #1840

Closed
@JsonFreeman

Description

@JsonFreeman

We can emit computed properties in ES5, using the following scheme:

var x = {
    a: 0,
    ["b"]: 0,
    ["c"]() {},
    get ["d"]() { return 0 },
    set ["d"](x) {},
    e: 0
};

emits as:

var x = {
    a: 0
};
x["b"]: 0;
x["c"] = function() {};
Object.defineProperty(x, "d" ...);
Object.defineProperty(x, "d" ...);
x.e = 0;

In any other expression context, we would emit a temp variable like we do for destructuring.

Metadata

Metadata

Labels

FixedA PR has been merged for this issueIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions