diff --git a/crates/oxc_query/src/edges.rs b/crates/oxc_query/src/edges.rs index 60844ff8c..915c70d5e 100644 --- a/crates/oxc_query/src/edges.rs +++ b/crates/oxc_query/src/edges.rs @@ -1725,6 +1725,7 @@ pub(super) fn resolve_variable_declaration_edge<'a, 'b: 'a>( match edge_name { "span" => variable_declaration::span(contexts, resolve_info), "left" => variable_declaration::left(contexts, resolve_info), + "right" => variable_declaration::right(contexts, resolve_info), "ancestor" => ancestors(contexts, adapter), "parent" => parents(contexts, adapter), _ => { @@ -1775,4 +1776,23 @@ mod variable_declaration { ))); }) } + + pub(super) fn right<'a, 'b: 'a>( + contexts: ContextIterator<'a, Vertex<'b>>, + _resolve_info: &ResolveEdgeInfo, + ) -> ContextOutcomeIterator<'a, Vertex<'b>, VertexIterator<'a, Vertex<'b>>> { + resolve_neighbors_with(contexts, |v| { + Box::new( + v.as_variable_declaration() + .unwrap_or_else(|| { + panic!("expected to have a typeannotation vertex, instead have: {v:#?}") + }) + .variable_declaration + .init + .as_ref() + .into_iter() + .map(Vertex::from), + ) + }) + } } diff --git a/crates/oxc_query/src/schema.graphql b/crates/oxc_query/src/schema.graphql index 12a8e002b..084642b3a 100644 --- a/crates/oxc_query/src/schema.graphql +++ b/crates/oxc_query/src/schema.graphql @@ -366,6 +366,7 @@ this will fire once per assignment. """ type VariableDeclarationAST implements VariableDeclaration & ASTNode & HasSpan { left: AssignmentType! + right: Expression # ASTNode parent: ASTNode ancestor: [ASTNode!]!