MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isAmbientFunctionSignature

Function isAmbientFunctionSignature

src/extraction/languages/typescript.ts:169–183  ·  view source on GitHub ↗
(node: SyntaxNode, filePath: string)

Source from the content-addressed store, hash-verified

167 * Mirrored in the kernel (tsjs/mod.rs `is_ambient_function_signature`).
168 */
169export function isAmbientFunctionSignature(node: SyntaxNode, filePath: string): boolean {
170 if (node.type !== 'function_signature') return false;
171 const declarationFile = DECLARATION_FILE.test(filePath);
172 let ambient = false;
173 for (let current = node.parent; current; current = current.parent) {
174 if (current.type === 'internal_module') return false;
175 if (current.type === 'module') {
176 // `declare module 'x'`; `module Foo {}` is a namespace.
177 if (getChildByField(current, 'name')?.type !== 'string') return false;
178 return declarationFile;
179 }
180 if (current.type === 'ambient_declaration') ambient = true;
181 }
182 return ambient || declarationFile;
183}
184
185export const typescriptExtractor: LanguageExtractor = {
186 preParse: (source, filePath) => blankExportTypeStar(blankFlowSyntax(source, filePath)),

Callers

nothing calls this directly

Calls 1

getChildByFieldFunction · 0.90

Tested by

no test coverage detected