Skip to content

Unoptimized destructuring compilation #11779

Open
@holiber

Description

@holiber

TypeScript Version: 2.0

Code

// source ts code
let i = 1000;
while (i--) {
  let [a, b, c] = [1, 2, 3];
}

Expected behavior:

// compiled by babel
var i = 1000;
while (i--) {
  var a = 1;
  var b = 2;
  var c = 3;
}

Actual behavior:

// compiled by tsc
var i = 1000;
while (i--) {
    var _a = [1, 2, 3], a = _a[0], b = _a[1], c = _a[2];
}

On each iteration tsc creates new unnecessary array _a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions