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

Function bindExportsPropertyAssignment

test/fixtures/snapshot/typescript.js:47162–47180  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

47160 }
47161 }
47162 function bindExportsPropertyAssignment(node) {
47163 // When we create a property via 'exports.foo = bar', the 'exports.foo' property access
47164 // expression is the declaration
47165 if (!setCommonJsModuleIndicator(node)) {
47166 return;
47167 }
47168 var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) {
47169 if (symbol) {
47170 addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */);
47171 }
47172 return symbol;
47173 });
47174 if (symbol) {
47175 var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression));
47176 var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */;
47177 ts.setParent(node.left, node);
47178 declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */);
47179 }
47180 }
47181 function bindModuleExportsAssignment(node) {
47182 // A common practice in node modules is to set 'export = module.exports = {}', this ensures that 'exports'
47183 // is still pointing to 'module.exports'.

Callers 2

bindWorkerFunction · 0.85

Calls 4

addDeclarationToSymbolFunction · 0.85
declareSymbolFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…