MCPcopy Create free account
hub / github.com/nodejs/node / isAnySymbolAccessible

Function isAnySymbolAccessible

test/fixtures/snapshot/typescript.js:52019–52081  ·  view source on GitHub ↗
(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules)

Source from the content-addressed store, hash-verified

52017 return access.accessibility === 0 /* SymbolAccessibility.Accessible */;
52018 }
52019 function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) {
52020 if (!ts.length(symbols))
52021 return;
52022 var hadAccessibleChain;
52023 var earlyModuleBail = false;
52024 for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
52025 var symbol = _a[_i];
52026 // Symbol is accessible if it by itself is accessible
52027 var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false);
52028 if (accessibleSymbolChain) {
52029 hadAccessibleChain = symbol;
52030 var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
52031 if (hasAccessibleDeclarations) {
52032 return hasAccessibleDeclarations;
52033 }
52034 }
52035 if (allowModules) {
52036 if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
52037 if (shouldComputeAliasesToMakeVisible) {
52038 earlyModuleBail = true;
52039 // Generally speaking, we want to use the aliases that already exist to refer to a module, if present
52040 // In order to do so, we need to find those aliases in order to retain them in declaration emit; so
52041 // if we are in declaration emit, we cannot use the fast path for module visibility until we've exhausted
52042 // all other visibility options (in order to capture the possible aliases used to reference the module)
52043 continue;
52044 }
52045 // Any meaning of a module symbol is always accessible via an `import` type
52046 return {
52047 accessibility: 0 /* SymbolAccessibility.Accessible */
52048 };
52049 }
52050 }
52051 // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
52052 // It could be a qualified symbol and hence verify the path
52053 // e.g.:
52054 // module m {
52055 // export class c {
52056 // }
52057 // }
52058 // const x: typeof m.c
52059 // In the above example when we start with checking if typeof m.c symbol is accessible,
52060 // we are going to see if c can be accessed in scope directly.
52061 // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible
52062 // It is accessible if the parent m is accessible because then m.c can be accessed through qualification
52063 var containers = getContainersOfSymbol(symbol, enclosingDeclaration, meaning);
52064 var parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible, allowModules);
52065 if (parentResult) {
52066 return parentResult;
52067 }
52068 }
52069 if (earlyModuleBail) {
52070 return {
52071 accessibility: 0 /* SymbolAccessibility.Accessible */
52072 };
52073 }
52074 if (hadAccessibleChain) {
52075 return {
52076 accessibility: 1 /* SymbolAccessibility.NotAccessible */,

Callers 1

isSymbolAccessibleWorkerFunction · 0.85

Calls 7

getAccessibleSymbolChainFunction · 0.85
hasVisibleDeclarationsFunction · 0.85
getContainersOfSymbolFunction · 0.85
getQualifiedLeftMeaningFunction · 0.85
symbolToStringFunction · 0.85
someMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected