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

Function determineIfDeclarationIsVisible

test/fixtures/snapshot/typescript.js:55488–55572  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55486 }
55487 return false;
55488 function determineIfDeclarationIsVisible() {
55489 switch (node.kind) {
55490 case 338 /* SyntaxKind.JSDocCallbackTag */:
55491 case 345 /* SyntaxKind.JSDocTypedefTag */:
55492 case 339 /* SyntaxKind.JSDocEnumTag */:
55493 // Top-level jsdoc type aliases are considered exported
55494 // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file
55495 return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
55496 case 203 /* SyntaxKind.BindingElement */:
55497 return isDeclarationVisible(node.parent.parent);
55498 case 254 /* SyntaxKind.VariableDeclaration */:
55499 if (ts.isBindingPattern(node.name) &&
55500 !node.name.elements.length) {
55501 // If the binding pattern is empty, this variable declaration is not visible
55502 return false;
55503 }
55504 // falls through
55505 case 261 /* SyntaxKind.ModuleDeclaration */:
55506 case 257 /* SyntaxKind.ClassDeclaration */:
55507 case 258 /* SyntaxKind.InterfaceDeclaration */:
55508 case 259 /* SyntaxKind.TypeAliasDeclaration */:
55509 case 256 /* SyntaxKind.FunctionDeclaration */:
55510 case 260 /* SyntaxKind.EnumDeclaration */:
55511 case 265 /* SyntaxKind.ImportEqualsDeclaration */:
55512 // external module augmentation is always visible
55513 if (ts.isExternalModuleAugmentation(node)) {
55514 return true;
55515 }
55516 var parent = getDeclarationContainer(node);
55517 // If the node is not exported or it is not ambient module element (except import declaration)
55518 if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) &&
55519 !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) {
55520 return isGlobalSourceFile(parent);
55521 }
55522 // Exported members/ambient module elements (exception import declaration) are visible if parent is visible
55523 return isDeclarationVisible(parent);
55524 case 167 /* SyntaxKind.PropertyDeclaration */:
55525 case 166 /* SyntaxKind.PropertySignature */:
55526 case 172 /* SyntaxKind.GetAccessor */:
55527 case 173 /* SyntaxKind.SetAccessor */:
55528 case 169 /* SyntaxKind.MethodDeclaration */:
55529 case 168 /* SyntaxKind.MethodSignature */:
55530 if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) {
55531 // Private/protected properties/methods are not visible
55532 return false;
55533 }
55534 // Public properties/methods are visible if its parents are visible, so:
55535 // falls through
55536 case 171 /* SyntaxKind.Constructor */:
55537 case 175 /* SyntaxKind.ConstructSignature */:
55538 case 174 /* SyntaxKind.CallSignature */:
55539 case 176 /* SyntaxKind.IndexSignature */:
55540 case 164 /* SyntaxKind.Parameter */:
55541 case 262 /* SyntaxKind.ModuleBlock */:
55542 case 179 /* SyntaxKind.FunctionType */:
55543 case 180 /* SyntaxKind.ConstructorType */:
55544 case 182 /* SyntaxKind.TypeLiteral */:
55545 case 178 /* SyntaxKind.TypeReference */:

Callers 1

isDeclarationVisibleFunction · 0.85

Calls 3

isDeclarationVisibleFunction · 0.85
getDeclarationContainerFunction · 0.85
isGlobalSourceFileFunction · 0.85

Tested by

no test coverage detected