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

Function addConstructor

test/fixtures/snapshot/typescript.js:99061–99080  ·  view source on GitHub ↗

* Adds the constructor of the class to a class body function. * * @param statements The statements of the class body function. * @param node The ClassExpression or ClassDeclaration node. * @param extendsClauseElement The expression for the class `extends` clause.

(statements, node, name, extendsClauseElement)

Source from the content-addressed store, hash-verified

99059 * @param extendsClauseElement The expression for the class `extends` clause.
99060 */
99061 function addConstructor(statements, node, name, extendsClauseElement) {
99062 var savedConvertedLoopState = convertedLoopState;
99063 convertedLoopState = undefined;
99064 var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */);
99065 var constructor = ts.getFirstConstructorWithBody(node);
99066 var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
99067 var constructorFunction = factory.createFunctionDeclaration(
99068 /*decorators*/ undefined,
99069 /*modifiers*/ undefined,
99070 /*asteriskToken*/ undefined, name,
99071 /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper),
99072 /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
99073 ts.setTextRange(constructorFunction, constructor || node);
99074 if (extendsClauseElement) {
99075 ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */);
99076 }
99077 statements.push(constructorFunction);
99078 exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
99079 convertedLoopState = savedConvertedLoopState;
99080 }
99081 /**
99082 * Transforms the parameters of the constructor declaration of a class.
99083 *

Callers 1

transformClassBodyFunction · 0.85

Calls 6

enterSubtreeFunction · 0.85
transformConstructorBodyFunction · 0.85
exitSubtreeFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…