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

Function declareModuleMember

test/fixtures/snapshot/typescript.js:45024–45065  ·  view source on GitHub ↗
(node, symbolFlags, symbolExcludes)

Source from the content-addressed store, hash-verified

45022 return symbol;
45023 }
45024 function declareModuleMember(node, symbolFlags, symbolExcludes) {
45025 var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node);
45026 if (symbolFlags & 2097152 /* SymbolFlags.Alias */) {
45027 if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) {
45028 return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
45029 }
45030 else {
45031 return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes);
45032 }
45033 }
45034 else {
45035 // Exported module members are given 2 symbols: A local symbol that is classified with an ExportValue flag,
45036 // and an associated export symbol with all the correct flags set on it. There are 2 main reasons:
45037 //
45038 // 1. We treat locals and exports of the same name as mutually exclusive within a container.
45039 // That means the binder will issue a Duplicate Identifier error if you mix locals and exports
45040 // with the same name in the same container.
45041 // TODO: Make this a more specific error and decouple it from the exclusion logic.
45042 // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol,
45043 // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
45044 // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
45045 // NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge
45046 // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
45047 // and this case is specially handled. Module augmentations should only be merged with original module definition
45048 // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
45049 if (ts.isJSDocTypeAlias(node))
45050 ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
45051 if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) {
45052 if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) {
45053 return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
45054 }
45055 var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0;
45056 var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes);
45057 local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
45058 node.localSymbol = local;
45059 return local;
45060 }
45061 else {
45062 return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes);
45063 }
45064 }
45065 }
45066 function jsdocTreatAsExported(node) {
45067 if (node.parent && ts.isModuleDeclaration(node)) {
45068 node = node.parent;

Callers 4

declareSourceFileMemberFunction · 0.85

Calls 4

jsdocTreatAsExportedFunction · 0.85
declareSymbolFunction · 0.85
getDeclarationNameFunction · 0.85
assertMethod · 0.80

Tested by

no test coverage detected