Address PR commennts

Update baselines with smaller emit as part of that.
This commit is contained in:
Nathan Shively-Sanders 2016-11-15 09:10:55 -08:00
parent 7c72f3db02
commit b9fa06f90b
8 changed files with 12 additions and 21 deletions

View File

@ -11193,9 +11193,8 @@ namespace ts {
let hasComputedStringProperty = false;
let hasComputedNumberProperty = false;
let i = 0;
let offset = 0;
for (i = 0; i < node.properties.length; i++) {
for (let i = 0; i < node.properties.length; i++) {
const memberDecl = node.properties[i];
let member = memberDecl.symbol;
if (memberDecl.kind === SyntaxKind.PropertyAssignment ||

View File

@ -45,7 +45,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
const restHelper = `
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) === -1)
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
return t;
};`;

View File

@ -326,7 +326,7 @@ namespace ts {
// Assignment for bindingTarget = value.propName should highlight whole property, hence use p as source map node
const propAccess = createDestructuringPropertyAccess(value, propName);
if (isComputedPropertyName(propName)) {
(computedTempVariables = computedTempVariables || []).push((propAccess as ElementAccessExpression).argumentExpression);
computedTempVariables = append(computedTempVariables, (propAccess as ElementAccessExpression).argumentExpression);
}
emitDestructuringAssignment(bindingTarget, propAccess, p);
}
@ -428,18 +428,11 @@ namespace ts {
}
if (isComputedPropertyName(getPropertyName(element))) {
// get the temp name and put that in there instead, like `_tmp + ""`
const stringifiedTemp = <StringLiteral>createSynthesizedNode(SyntaxKind.StringLiteral);
stringifiedTemp.pos = location.pos;
stringifiedTemp.end = location.end;
stringifiedTemp.text = "";
propertyNames.push(createBinary(computedTempVariables.shift(), SyntaxKind.PlusToken, stringifiedTemp));
propertyNames.push(createBinary(computedTempVariables.shift(), SyntaxKind.PlusToken, createLiteral("")));
}
else {
const str = <StringLiteral>createSynthesizedNode(SyntaxKind.StringLiteral);
str.pos = location.pos;
str.end = location.end;
str.text = getTextOfPropertyName(getPropertyName(element));
propertyNames.push(str);
const propName = getTextOfPropertyName(getPropertyName(element));
propertyNames.push(createLiteral(propName, location));
}
}
const args = createSynthesizedNodeArray([value, createArrayLiteral(propertyNames, location)]);
@ -569,11 +562,10 @@ namespace ts {
bindingElements = [];
}
// Rewrite element to a declaration with an initializer that fetches property
// TODO: Probably save the result of createDestructuringPropertyAccess if propName is a computed property
const propName = element.propertyName || <Identifier>element.name;
const propAccess = createDestructuringPropertyAccess(value, propName);
if (isComputedPropertyName(propName)) {
(computedTempVariables = computedTempVariables || []).push((propAccess as ElementAccessExpression).argumentExpression);
computedTempVariables = append(computedTempVariables, (propAccess as ElementAccessExpression).argumentExpression);
}
emitBindingElement(element, propAccess);
}

View File

@ -41,7 +41,7 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
//// [objectRest.js]
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) === -1)
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
return t;
};

View File

@ -17,7 +17,7 @@ var { a: [{ ...nested2 }, ...y], b: { z, ...c }, ...rest2 } = overEmit;
//// [objectRestAssignment.js]
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) === -1)
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
return t;
};

View File

@ -25,7 +25,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) === -1)
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
return t;
};

View File

@ -15,7 +15,7 @@ let rest: { b: string }
//// [objectRestNegative.js]
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) === -1)
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
return t;
};

View File

@ -11,7 +11,7 @@ suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo'
//// [objectRestParameter.js]
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) === -1)
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
return t;
};