Microsoft/TypeScript

Unoptimized destructuring compilation

Open

#11.779 aperta il 21 ott 2016

Vedi su GitHub
 (6 commenti) (1 reazione) (0 assegnatari)TypeScript (6726 fork)batch import
Help WantedSuggestion

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

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.

Guida contributor