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

Function is_ambient_export

codegraph-kernel/src/tsjs/mod.rs:1174–1198  ·  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

1172/// 'x' { … }` or `declare global { … }` body, which TypeScript exports without
1173/// an `export` keyword unless the body holds an export declaration of its own.
1174fn is_ambient_export(node: Node) -> bool {
1175 let mut cur = node.parent();
1176 while let Some(p) = cur {
1177 if p.kind() == "statement_block" && has_export_declaration(p) {
1178 return false;
1179 }
1180 if p.kind() == "ambient_declaration" {
1181 // `declare global` is the keyword and a bare block, with no field names.
1182 for i in 0..p.child_count() {
1183 if p.child(i).is_some_and(|c| c.kind() == "global") {
1184 return true;
1185 }
1186 }
1187 if let Some(declared) = p.named_child(0) {
1188 if declared.kind() == "module"
1189 && declared.child_by_field_name("name").is_some_and(|n| n.kind() == "string")
1190 {
1191 return true;
1192 }
1193 }
1194 }
1195 cur = p.parent();
1196 }
1197 false
1198}
1199
1200/// isAmbientFunctionSignature (languages/typescript.ts): a bodiless
1201/// `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