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

Function visitPropertyNameOfClassElement

test/fixtures/snapshot/typescript.js:93091–93107  ·  view source on GitHub ↗

* Visits the property name of a class element, for use when emitting property * initializers. For a computed property on a node with decorators, a temporary * value is stored for later use. * * @param member The member whose name should be visited.

(member)

Source from the content-addressed store, hash-verified

93089 * @param member The member whose name should be visited.
93090 */
93091 function visitPropertyNameOfClassElement(member) {
93092 var name = member.name;
93093 // Computed property names need to be transformed into a hoisted variable when they are used more than once.
93094 // The names are used more than once when:
93095 // - the property is non-static and its initializer is moved to the constructor (when there are parameter property assignments).
93096 // - the property has a decorator.
93097 if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
93098 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
93099 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
93100 if (!ts.isSimpleInlineableExpression(innerExpression)) {
93101 var generatedName = factory.getGeneratedNameForNode(name);
93102 hoistVariableDeclaration(generatedName);
93103 return factory.updateComputedPropertyName(name, factory.createAssignment(generatedName, expression));
93104 }
93105 }
93106 return ts.visitNode(name, visitor, ts.isPropertyName);
93107 }
93108 /**
93109 * Transforms a HeritageClause with TypeScript syntax.
93110 *

Callers 4

visitPropertyDeclarationFunction · 0.85
visitMethodDeclarationFunction · 0.85
visitGetAccessorFunction · 0.85
visitSetAccessorFunction · 0.85

Calls 2

hoistVariableDeclarationFunction · 0.85
someMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…