diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index 98ac44e7c6c7e..e4b6e85877d9e 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -187,6 +187,24 @@ impl<'a> Expression<'a> { } } + #[allow(missing_docs)] + #[must_use] + pub fn into_inner_expression(self) -> Expression<'a> { + let mut expr = self; + loop { + expr = match expr { + Expression::ParenthesizedExpression(e) => e.unbox().expression, + Expression::TSAsExpression(e) => e.unbox().expression, + Expression::TSSatisfiesExpression(e) => e.unbox().expression, + Expression::TSInstantiationExpression(e) => e.unbox().expression, + Expression::TSNonNullExpression(e) => e.unbox().expression, + Expression::TSTypeAssertion(e) => e.unbox().expression, + _ => break, + }; + } + expr + } + #[allow(missing_docs)] pub fn get_inner_expression(&self) -> &Expression<'a> { let mut expr = self;