@jsdocs-io/extractor
Version:
The API extractor for npm packages powering jsdocs.io
23 lines (22 loc) • 772 B
JavaScript
import { Node, } from "ts-morph";
/** `isGlobal` checks if a declaration is a global ambient declaration. */
export function isGlobal(node) {
const isGlobalVariable = Node.isVariableDeclaration(node) &&
node.getVariableStatementOrThrow().isAmbient() &&
!node.isExported();
if (isGlobalVariable)
return true;
const isGlobalFunction = Node.isFunctionDeclaration(node) &&
node.isAmbient() &&
node.getName() !== undefined &&
!node.isExported();
if (isGlobalFunction)
return true;
const isGlobalNamespace = Node.isModuleDeclaration(node) &&
node.isAmbient() &&
!node.isExported() &&
!node.hasModuleKeyword();
if (isGlobalNamespace)
return true;
return false;
}