diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index 12eea6b7b7562..4ee23597155e3 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -33,12 +33,11 @@ impl<'a> ParserImpl<'a> { } } - pub(crate) fn parse_using(&mut self) -> Result> { - let using_decl = self.parse_using_declaration(StatementContext::StatementList)?; - + pub(crate) fn parse_using_statement(&mut self) -> Result> { + let mut decl = self.parse_using_declaration(StatementContext::StatementList)?; self.asi()?; - - Ok(Statement::VariableDeclaration(self.alloc(using_decl))) + decl.span = self.end_span(decl.span); + Ok(Statement::VariableDeclaration(self.alloc(decl))) } pub(crate) fn parse_variable_declaration( diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index bfe0fb24010c7..cbbf1e0e66972 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -123,9 +123,9 @@ impl<'a> ParserImpl<'a> { Kind::Await if self.peek_kind() == Kind::Using && self.nth_kind(2).is_binding_identifier() => { - self.parse_using() + self.parse_using_statement() } - Kind::Using if self.peek_kind().is_binding_identifier() => self.parse_using(), + Kind::Using if self.peek_kind().is_binding_identifier() => self.parse_using_statement(), Kind::Async if self.peek_at(Kind::Function) && !self.peek_token().is_on_new_line => { self.parse_function_declaration(stmt_ctx) }