* Creates either a PropertyAccessExpression or an ElementAccessExpression for the * right-hand side of a transformed destructuring assignment. * * @link https://tc39.github.io/ecma262/#sec-runtime-semantics-keyeddestructuringassignmentevaluation * * @param flattenContext Opt
(flattenContext, value, propertyName)
| 91391 | * @param propertyName The destructuring property name. |
| 91392 | */ |
| 91393 | function createDestructuringPropertyAccess(flattenContext, value, propertyName) { |
| 91394 | if (ts.isComputedPropertyName(propertyName)) { |
| 91395 | var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), /*reuseIdentifierExpressions*/ false, /*location*/ propertyName); |
| 91396 | return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression); |
| 91397 | } |
| 91398 | else if (ts.isStringOrNumericLiteralLike(propertyName)) { |
| 91399 | var argumentExpression = ts.factory.cloneNode(propertyName); |
| 91400 | return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression); |
| 91401 | } |
| 91402 | else { |
| 91403 | var name = flattenContext.context.factory.createIdentifier(ts.idText(propertyName)); |
| 91404 | return flattenContext.context.factory.createPropertyAccessExpression(value, name); |
| 91405 | } |
| 91406 | } |
| 91407 | /** |
| 91408 | * Ensures that there exists a declared identifier whose value holds the given expression. |
| 91409 | * This function is useful to ensure that the expression's value can be read from in subsequent expressions. |
no test coverage detected