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

Function createSuperAccessVariableStatement

test/fixtures/snapshot/typescript.js:96434–96476  ·  view source on GitHub ↗

Creates a variable named `_super` with accessor properties for the given property names.

(factory, resolver, node, names)

Source from the content-addressed store, hash-verified

96432 ts.transformES2017 = transformES2017;
96433 /** Creates a variable named `_super` with accessor properties for the given property names. */
96434 function createSuperAccessVariableStatement(factory, resolver, node, names) {
96435 // Create a variable declaration with a getter/setter (if binding) definition for each name:
96436 // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
96437 var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
96438 var accessors = [];
96439 names.forEach(function (_, key) {
96440 var name = ts.unescapeLeadingUnderscores(key);
96441 var getterAndSetter = [];
96442 getterAndSetter.push(factory.createPropertyAssignment("get", factory.createArrowFunction(
96443 /* modifiers */ undefined,
96444 /* typeParameters */ undefined,
96445 /* parameters */ [],
96446 /* type */ undefined,
96447 /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */))));
96448 if (hasBinding) {
96449 getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction(
96450 /* modifiers */ undefined,
96451 /* typeParameters */ undefined,
96452 /* parameters */ [
96453 factory.createParameterDeclaration(
96454 /* decorators */ undefined,
96455 /* modifiers */ undefined,
96456 /* dotDotDotToken */ undefined, "v",
96457 /* questionToken */ undefined,
96458 /* type */ undefined,
96459 /* initializer */ undefined)
96460 ],
96461 /* type */ undefined,
96462 /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v")))));
96463 }
96464 accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter)));
96465 });
96466 return factory.createVariableStatement(
96467 /* modifiers */ undefined, factory.createVariableDeclarationList([
96468 factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
96469 /*exclamationToken*/ undefined,
96470 /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"),
96471 /* typeArguments */ undefined, [
96472 factory.createNull(),
96473 factory.createObjectLiteralExpression(accessors, /* multiline */ true)
96474 ]))
96475 ], 2 /* NodeFlags.Const */));
96476 }
96477 ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
96478})(ts || (ts = {}));
96479/*@internal*/

Callers 1

Calls 2

forEachMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…