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

Function getExportsOfModuleWorker

test/fixtures/snapshot/typescript.js:51504–51544  ·  view source on GitHub ↗
(moduleSymbol)

Source from the content-addressed store, hash-verified

51502 });
51503 }
51504 function getExportsOfModuleWorker(moduleSymbol) {
51505 var visitedSymbols = [];
51506 // A module defined by an 'export=' consists of one export that needs to be resolved
51507 moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
51508 return visit(moduleSymbol) || emptySymbols;
51509 // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example,
51510 // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error.
51511 function visit(symbol) {
51512 if (!(symbol && symbol.exports && ts.pushIfUnique(visitedSymbols, symbol))) {
51513 return;
51514 }
51515 var symbols = new ts.Map(symbol.exports);
51516 // All export * declarations are collected in an __export symbol by the binder
51517 var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */);
51518 if (exportStars) {
51519 var nestedSymbols = ts.createSymbolTable();
51520 var lookupTable_1 = new ts.Map();
51521 if (exportStars.declarations) {
51522 for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) {
51523 var node = _a[_i];
51524 var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
51525 var exportedSymbols = visit(resolvedModule);
51526 extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node);
51527 }
51528 }
51529 lookupTable_1.forEach(function (_a, id) {
51530 var exportsWithDuplicate = _a.exportsWithDuplicate;
51531 // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself
51532 if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) {
51533 return;
51534 }
51535 for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) {
51536 var node = exportsWithDuplicate_1[_i];
51537 diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, ts.unescapeLeadingUnderscores(id)));
51538 }
51539 });
51540 extendExportSymbols(symbols, nestedSymbols);
51541 }
51542 return symbols;
51543 }
51544 }
51545 function getMergedSymbol(symbol) {
51546 var merged;
51547 return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol;

Callers 2

getExportsOfModuleFunction · 0.85

Calls 2

visitFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…