@jsdocs-io/extractor
Version:
The API extractor for npm packages powering jsdocs.io
20 lines (19 loc) • 831 B
JavaScript
import { isGlobal } from "./is-global.js";
import { isHidden } from "./is-hidden.js";
export function globalAmbientDeclarations(containerName, container) {
// See https://www.typescriptlang.org/docs/handbook/declaration-files/by-example.html#global-variables.
const globalCandidates = [
...container.getVariableDeclarations(),
...container.getFunctions(),
...container.getModules(),
];
const globalAmbientDeclarations = [];
for (const declaration of globalCandidates) {
if (!isGlobal(declaration) || isHidden(declaration))
continue;
// Global ambient functions must have a name.
const exportName = declaration.getName();
globalAmbientDeclarations.push({ containerName, exportName, declaration });
}
return globalAmbientDeclarations;
}