MCPcopy Index your code
hub / github.com/nodejs/node / getPropertyNameExpressionIfNeeded

Function getPropertyNameExpressionIfNeeded

test/fixtures/snapshot/typescript.js:95536–95554  ·  view source on GitHub ↗

* If the name is a computed property, this function transforms it, then either returns an expression which caches the * value of the result or the expression itself if the value is either unused or safe to inline into multiple locations * @param shouldHoist Does the expression need

(name, shouldHoist)

Source from the content-addressed store, hash-verified

95534 * @param shouldHoist Does the expression need to be reused? (ie, for an initializer or a decorator)
95535 */
95536 function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
95537 if (ts.isComputedPropertyName(name)) {
95538 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
95539 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
95540 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
95541 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
95542 if (!alreadyTransformed && !inlinable && shouldHoist) {
95543 var generatedName = factory.getGeneratedNameForNode(name);
95544 if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) {
95545 addBlockScopedVariable(generatedName);
95546 }
95547 else {
95548 hoistVariableDeclaration(generatedName);
95549 }
95550 return factory.createAssignment(generatedName, expression);
95551 }
95552 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
95553 }
95554 }
95555 function startClassLexicalEnvironment() {
95556 classLexicalEnvironmentStack.push(currentClassLexicalEnvironment);
95557 currentClassLexicalEnvironment = undefined;

Callers 1

visitPropertyDeclarationFunction · 0.85

Calls 2

addBlockScopedVariableFunction · 0.85
hoistVariableDeclarationFunction · 0.85

Tested by

no test coverage detected