Skip to content

Computed properties in destructuring patterns are not recognized #4917

Closed
@weswigham

Description

@weswigham

We compile this:

let foo = "bar";
let {[foo]: bar} = {bar: "bar"};

to this:

var foo = "bar";
var _a = [foo], bar;
{
    bar: "bar";
}
;

(and error on the syntax)
whereas babel compiles it cleanly to this:

"use strict";

var foo = "bar";
var _bar = { bar: "bar" };
var bar = _bar[foo];

Babel's output functions as expected, ours does not.

There's a section on this on the MDN article on destructuring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptES6Relates to the ES6 SpecFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions