isAmbientExport (languages/typescript.ts): declared in a `declare module 'x' { … }` or `declare global { … }` body, which TypeScript exports without an `export` keyword unless the body holds an export declaration of its own.
(node: Node)
| 1286 | /// 'x' { … }` or `declare global { … }` body, which TypeScript exports without |
| 1287 | /// an `export` keyword unless the body holds an export declaration of its own. |
| 1288 | fn is_ambient_export(node: Node) -> bool { |
| 1289 | let mut cur = node.parent(); |
| 1290 | while let Some(p) = cur { |
| 1291 | if p.kind() == "statement_block" && has_export_declaration(p) { |
| 1292 | return false; |
| 1293 | } |
| 1294 | if p.kind() == "ambient_declaration" { |
| 1295 | // `declare global` is the keyword and a bare block, with no field names. |
| 1296 | for i in 0..p.child_count() { |
| 1297 | if p.child(i).is_some_and(|c| c.kind() == "global") { |
| 1298 | return true; |
| 1299 | } |
| 1300 | } |
| 1301 | if let Some(declared) = p.named_child(0) { |
| 1302 | if declared.kind() == "module" |
| 1303 | && declared.child_by_field_name("name").is_some_and(|n| n.kind() == "string") |
| 1304 | { |
| 1305 | return true; |
| 1306 | } |
| 1307 | } |
| 1308 | } |
| 1309 | cur = p.parent(); |
| 1310 | } |
| 1311 | false |
| 1312 | } |
| 1313 | |
| 1314 | /// isAmbientFunctionSignature (languages/typescript.ts): a bodiless |
| 1315 | /// `function_signature` that is a function's declaration, not an overload of |
no test coverage detected