Visit destructuring computed names (#18052)
This commit is contained in:
parent
69a8504d59
commit
38c3f67652
|
@ -409,7 +409,7 @@ namespace ts {
|
|||
*/
|
||||
function createDestructuringPropertyAccess(flattenContext: FlattenContext, value: Expression, propertyName: PropertyName): LeftHandSideExpression {
|
||||
if (isComputedPropertyName(propertyName)) {
|
||||
const argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, /*reuseIdentifierExpressions*/ false, /*location*/ propertyName);
|
||||
const argumentExpression = ensureIdentifier(flattenContext, visitNode(propertyName.expression, flattenContext.visitor), /*reuseIdentifierExpressions*/ false, /*location*/ propertyName);
|
||||
return createElementAccess(value, argumentExpression);
|
||||
}
|
||||
else if (isStringOrNumericLiteral(propertyName)) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
//// [computerPropertiesInES5ShouldBeTransformed.ts]
|
||||
const b = ({ [`key`]: renamed }) => renamed;
|
||||
|
||||
//// [computerPropertiesInES5ShouldBeTransformed.js]
|
||||
var b = function (_a) {
|
||||
var _b = "key", renamed = _a[_b];
|
||||
return renamed;
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
=== tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts ===
|
||||
const b = ({ [`key`]: renamed }) => renamed;
|
||||
>b : Symbol(b, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 5))
|
||||
>renamed : Symbol(renamed, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 12))
|
||||
>renamed : Symbol(renamed, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 12))
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts ===
|
||||
const b = ({ [`key`]: renamed }) => renamed;
|
||||
>b : ({ [`key`]: renamed }: {}) => any
|
||||
>({ [`key`]: renamed }) => renamed : ({ [`key`]: renamed }: {}) => any
|
||||
>`key` : "key"
|
||||
>renamed : any
|
||||
>renamed : any
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
// @target: es5
|
||||
const b = ({ [`key`]: renamed }) => renamed;
|
Loading…
Reference in a new issue