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)
| 1187 | /// 'x' { … }` or `declare global { … }` body, which TypeScript exports without |
| 1188 | /// an `export` keyword unless the body holds an export declaration of its own. |
| 1189 | fn is_ambient_export(node: Node) -> bool { |
| 1190 | let mut cur = node.parent(); |
| 1191 | while let Some(p) = cur { |
| 1192 | if p.kind() == "statement_block" && has_export_declaration(p) { |
| 1193 | return false; |
| 1194 | } |
| 1195 | if p.kind() == "ambient_declaration" { |
| 1196 | // `declare global` is the keyword and a bare block, with no field names. |
| 1197 | for i in 0..p.child_count() { |
| 1198 | if p.child(i).is_some_and(|c| c.kind() == "global") { |
| 1199 | return true; |
| 1200 | } |
| 1201 | } |
| 1202 | if let Some(declared) = p.named_child(0) { |
| 1203 | if declared.kind() == "module" |
| 1204 | && declared.child_by_field_name("name").is_some_and(|n| n.kind() == "string") |
| 1205 | { |
| 1206 | return true; |
| 1207 | } |
| 1208 | } |
| 1209 | } |
| 1210 | cur = p.parent(); |
| 1211 | } |
| 1212 | false |
| 1213 | } |
| 1214 | |
| 1215 | /// isAmbientFunctionSignature (languages/typescript.ts): a bodiless |
| 1216 | /// `function_signature` that is a function's declaration, not an overload of |
no test coverage detected