mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Address PR commennts
Update baselines with smaller emit as part of that.
This commit is contained in:
parent
7c72f3db02
commit
b9fa06f90b
@ -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 ||
|
||||
|
||||
@ -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;
|
||||
};`;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user