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

Function isSymbolFromTypeDeclarationFile

test/fixtures/snapshot/typescript.js:87426–87455  ·  view source on GitHub ↗
(symbol)

Source from the content-addressed store, hash-verified

87424 return typeReferenceDirectives;
87425 }
87426 function isSymbolFromTypeDeclarationFile(symbol) {
87427 // bail out if symbol does not have associated declarations (i.e. this is transient symbol created for property in binding pattern)
87428 if (!symbol.declarations) {
87429 return false;
87430 }
87431 // walk the parent chain for symbols to make sure that top level parent symbol is in the global scope
87432 // external modules cannot define or contribute to type declaration files
87433 var current = symbol;
87434 while (true) {
87435 var parent = getParentOfSymbol(current);
87436 if (parent) {
87437 current = parent;
87438 }
87439 else {
87440 break;
87441 }
87442 }
87443 if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) {
87444 return false;
87445 }
87446 // check that at least one declaration of top level symbol originates from type declaration file
87447 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
87448 var decl = _a[_i];
87449 var file = ts.getSourceFileOfNode(decl);
87450 if (fileToDirective.has(file.path)) {
87451 return true;
87452 }
87453 }
87454 return false;
87455 }
87456 function addReferencedFilesToTypeDirective(file, key, mode) {
87457 if (fileToDirective.has(file.path))
87458 return;

Callers 1

Calls 2

getParentOfSymbolFunction · 0.85
hasMethod · 0.65

Tested by

no test coverage detected