API reference for the AST module: Option-returning matchers with dual API for member expressions, calls, imports, node narrowing, and ancestor traversal.
Use this file to discover all available pages before exploring further.
The AST module provides safe, composable pattern matching helpers for ESTree nodes. Every matcher returns an Option value, making it natural to chain with Option.map, Option.flatMap, and pipe. All public combinators support a dual API: call them data-first (pass the node as the first argument) or data-last (pass only the config and receive a curried function for use in pipe).
Matches a MemberExpression of the form obj.prop where obj is an identifier with the given name and prop matches one of the given property names. Returns Option<ESTree.StaticMemberExpression>.
Matches a CallExpression whose callee is obj.prop(...). Returns the call expression narrowed to confirm its callee is a static member expression: Option<ESTree.CallExpression>.
Extracts the callee identifier name from a CallExpression or NewExpression when the callee is a bare identifier. Unifies callee-name extraction across both node shapes.
Narrows an ESTree.Node to a specific type string. Returns Option<ESTree.Node & { readonly type: T }>. A safe alternative to casting — returns Option.none() if the node’s type doesn’t match.
export const narrow: { <T extends string>( type: T ): (node: ESTree.Node) => Option.Option<ESTree.Node & { readonly type: T }>}
AST.narrow(node, 'CallExpression') // data-firstpipe(node, AST.narrow('CallExpression')) // data-last// Chain to get a fully typed nodepipe( AST.narrow(node, 'CallExpression'), Option.flatMap(AST.matchCallOf('Effect', 'gen')))
Extracts the full member path from a (possibly chained) MemberExpression. Walks a.b.c to ['a', 'b', 'c']. Returns Option.none() if any segment is computed or non-identifier.
Walks the .parent chain and returns the first ancestor whose type matches the given string literal. Returns Option<{ readonly type: T; readonly parent?: unknown }>.