(node: SyntaxNode, filePath: string)
| 167 | * Mirrored in the kernel (tsjs/mod.rs `is_ambient_function_signature`). |
| 168 | */ |
| 169 | export 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 | |
| 185 | export const typescriptExtractor: LanguageExtractor = { |
| 186 | preParse: (source, filePath) => blankExportTypeStar(blankFlowSyntax(source, filePath)), |
nothing calls this directly
no test coverage detected