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

Function is_ambient_export

codegraph-kernel/src/tsjs/mod.rs:1288–1312  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1286/// 'x' { … }` or `declare global { … }` body, which TypeScript exports without
1287/// an `export` keyword unless the body holds an export declaration of its own.
1288fn 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

Callers 1

is_exportedMethod · 0.85

Calls 1

has_export_declarationFunction · 0.85

Tested by

no test coverage detected