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)
| 1161 | /// 'x' { … }` or `declare global { … }` body, which TypeScript exports without |
| 1162 | /// an `export` keyword unless the body holds an export declaration of its own. |
| 1163 | fn is_ambient_export(node: Node) -> bool { |
| 1164 | let mut cur = node.parent(); |
| 1165 | while let Some(p) = cur { |
| 1166 | if p.kind() == "statement_block" && has_export_declaration(p) { |
| 1167 | return false; |
| 1168 | } |
| 1169 | if p.kind() == "ambient_declaration" { |
| 1170 | // `declare global` is the keyword and a bare block, with no field names. |
| 1171 | for i in 0..p.child_count() { |
| 1172 | if p.child(i).is_some_and(|c| c.kind() == "global") { |
| 1173 | return true; |
| 1174 | } |
| 1175 | } |
| 1176 | if let Some(declared) = p.named_child(0) { |
| 1177 | if declared.kind() == "module" |
| 1178 | && declared.child_by_field_name("name").is_some_and(|n| n.kind() == "string") |
| 1179 | { |
| 1180 | return true; |
| 1181 | } |
| 1182 | } |
| 1183 | } |
| 1184 | cur = p.parent(); |
| 1185 | } |
| 1186 | false |
| 1187 | } |
| 1188 | |
| 1189 | /// isAmbientFunctionSignature (languages/typescript.ts): a bodiless |
| 1190 | /// `function_signature` that is a function's declaration, not an overload of |
no test coverage detected