diff --git a/crates/oxc_codegen/tests/integration/snapshots/minify.snap b/crates/oxc_codegen/tests/integration/snapshots/minify.snap index f065931177a61..cec662af88cd6 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/minify.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/minify.snap @@ -219,3 +219,12 @@ export import b = require("b"); ---------- import a = require("a");export import b = require("b"); +########## 41 +class C { + static + static + static + bar() {} +} +---------- +class C{static static;static bar(){}} diff --git a/crates/oxc_codegen/tests/integration/snapshots/ts.snap b/crates/oxc_codegen/tests/integration/snapshots/ts.snap index 5ecabfcf3cb25..bbd3b9fecdb20 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/ts.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/ts.snap @@ -331,3 +331,16 @@ export import b = require("b"); ---------- import a = require('a'); export import b = require('b'); + +########## 41 +class C { + static + static + static + bar() {} +} +---------- +class C { + static static; + static bar() {} +} diff --git a/crates/oxc_codegen/tests/integration/ts.rs b/crates/oxc_codegen/tests/integration/ts.rs index 6b0ff75024e81..9a751c1b53507 100644 --- a/crates/oxc_codegen/tests/integration/ts.rs +++ b/crates/oxc_codegen/tests/integration/ts.rs @@ -118,6 +118,12 @@ export { default as name16 } from "module-name"; import a = require("a"); export import b = require("b"); "#, + "class C { + static + static + static + bar() {} +}", ]; snapshot("ts", &cases); diff --git a/crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs b/crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs index 1551c7ea894a8..04e6be287393b 100644 --- a/crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs +++ b/crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs @@ -1800,7 +1800,6 @@ mod test { "class C { static accessor ['__proto__'] = 0 }", "class C { static accessor __proto__ = 0 }", ); - test("class C { static static ['__proto__']() {} }", "class C { static __proto__() {} }"); // // diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index 0abe69472d6d3..14718c9de8951 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -463,13 +463,6 @@ pub fn using_declarations_must_be_initialized(span: Span) -> OxcDiagnostic { OxcDiagnostic::error("Using declarations must have an initializer.").with_label(span) } -/// TS(1093) -#[cold] -pub fn static_constructor(span: Span) -> OxcDiagnostic { - ts_error("1089", "`static` modifier cannot appear on a constructor declaration.") - .with_label(span) -} - #[cold] pub fn jsx_element_no_match(span: Span, span1: Span, name: &str) -> OxcDiagnostic { OxcDiagnostic::error(format!("Expected corresponding JSX closing tag for '{name}'.")) diff --git a/crates/oxc_parser/src/js/class.rs b/crates/oxc_parser/src/js/class.rs index ac0bf162db1cb..1790ec5a69f10 100644 --- a/crates/oxc_parser/src/js/class.rs +++ b/crates/oxc_parser/src/js/class.rs @@ -1,7 +1,7 @@ use oxc_allocator::{Box, Vec}; use oxc_ast::ast::*; use oxc_ecmascript::PropName; -use oxc_span::{GetSpan, Span}; +use oxc_span::Span; use crate::{ Context, ParserImpl, StatementContext, diagnostics, @@ -177,371 +177,426 @@ impl<'a> ParserImpl<'a> { fn parse_class_body(&mut self) -> Box<'a, ClassBody<'a>> { let span = self.start_span(); - let class_elements = - self.parse_normal_list(Kind::LCurly, Kind::RCurly, Self::parse_class_element); + let class_elements = self.parse_normal_list(Kind::LCurly, Kind::RCurly, |p| { + // skip empty class element `;` + while p.at(Kind::Semicolon) { + p.bump_any(); + } + if p.at(Kind::RCurly) { + return None; + } + Some(Self::parse_class_element(p)) + }); self.ast.alloc_class_body(self.end_span(span), class_elements) } - pub(crate) fn parse_class_element(&mut self) -> Option> { - // skip empty class element `;` - while self.at(Kind::Semicolon) { - self.bump_any(); - } - if self.at(Kind::RCurly) { - return None; - } - + pub(crate) fn parse_class_element(&mut self) -> ClassElement<'a> { let span = self.start_span(); - let modifiers = self.parse_modifiers(true, true, true); - - let mut kind = MethodDefinitionKind::Method; - let mut generator = false; + let modifiers = self.parse_modifiers( + /* alloc_class_body */ true, /* permit_const_as_modifier */ true, + /* stop_on_start_of_class_static_block */ true, + ); - let mut key_name = None; + // static { block } + if self.at(Kind::Static) && self.peek_at(Kind::LCurly) { + return self.parse_class_static_block(span); + } - let accessibility = modifiers.accessibility(); - let accessor = modifiers.contains(ModifierKind::Accessor); - let declare = modifiers.contains(ModifierKind::Declare); - let readonly = modifiers.contains(ModifierKind::Readonly); - let r#override = modifiers.contains(ModifierKind::Override); let r#abstract = modifiers.contains(ModifierKind::Abstract); - let mut r#static = modifiers.contains(ModifierKind::Static); - let mut r#async = modifiers.contains(ModifierKind::Async); - - if self.at(Kind::Static) { - // static { block } - if self.peek_at(Kind::LCurly) { - self.bump(Kind::Static); - return Some(self.parse_class_static_block(span)); - } - // static ... - if self.peek_kind().is_class_element_name_start() || self.peek_at(Kind::Star) { - self.bump(Kind::Static); - r#static = true; - } else { - key_name = Some(self.parse_class_element_name()); - } + let r#type = if r#abstract { + MethodDefinitionType::TSAbstractMethodDefinition + } else { + MethodDefinitionType::MethodDefinition + }; + + let cur_kind = self.cur_kind(); + if matches!(cur_kind, Kind::Get | Kind::Set) + && self.try_parse(Self::next_token_can_follow_modifier).is_some() + { + let kind = match cur_kind { + Kind::Get => MethodDefinitionKind::Get, + Kind::Set => MethodDefinitionKind::Set, + _ => unreachable!(), + }; + return self.parse_accessor_declaration(span, r#type, kind, &modifiers); } - // async ... - if key_name.is_none() && self.at(Kind::Async) && !self.peek_at(Kind::Question) { - if !self.peek_token().is_on_new_line() - && (self.peek_kind().is_class_element_name_start() || self.peek_at(Kind::Star)) - { - self.bump(Kind::Async); - r#async = true; - } else { - key_name = Some(self.parse_class_element_name()); + if matches!(cur_kind, Kind::Constructor | Kind::Str) + && !modifiers.contains(ModifierKind::Static) + { + let constructor_declaration = + self.try_parse_constructor_declaration(span, r#type, &modifiers); + if let Some(c) = constructor_declaration { + return c; } } - if self.is_at_ts_index_signature_member() { + if self.is_index_signature() { let decl = self.parse_index_signature_declaration(span, &modifiers); - return Some(ClassElement::TSIndexSignature(self.alloc(decl))); + return ClassElement::TSIndexSignature(self.alloc(decl)); } - // * ... - if key_name.is_none() && self.eat(Kind::Star) { - generator = true; + let kind = self.cur_kind(); + if kind.is_identifier_or_keyword() + || kind.is_number() + || kind == Kind::Star + || kind == Kind::LBrack + { + let is_ambient = modifiers.contains(ModifierKind::Declare); + return if is_ambient { + self.context(Context::Ambient, Context::empty(), |p| { + p.parse_property_or_method_declaration(span, r#type, &modifiers) + }) + } else { + self.parse_property_or_method_declaration(span, r#type, &modifiers) + }; } - if key_name.is_none() && !r#async && !generator { - // get ... / set ... - let peeked_class_element = self.peek_kind().is_class_element_name_start(); - key_name = match self.cur_kind() { - Kind::Get if peeked_class_element => { - self.bump(Kind::Get); - kind = MethodDefinitionKind::Get; - Some(self.parse_class_element_name()) + self.unexpected() + } + + fn parse_class_element_name(&mut self, modifiers: &Modifiers<'a>) -> (PropertyKey<'a>, bool) { + if let Some(modifier) = modifiers.iter().find(|m| m.kind == ModifierKind::Const) { + self.error(diagnostics::const_class_member(modifier.span)); + } + match self.cur_kind() { + Kind::PrivateIdentifier => { + let private_ident = self.parse_private_identifier(); + // `private #foo`, etc. is illegal + if self.is_ts { + self.verify_modifiers( + modifiers, + ModifierFlags::all() - ModifierFlags::ACCESSIBILITY, + diagnostics::accessibility_modifier_on_private_property, + ); } - Kind::Set if peeked_class_element => { - self.bump(Kind::Set); - kind = MethodDefinitionKind::Set; - Some(self.parse_class_element_name()) + if private_ident.name == "constructor" { + self.error(diagnostics::private_name_constructor(private_ident.span)); } - kind if kind.is_class_element_name_start() => Some(self.parse_class_element_name()), - _ => return self.unexpected(), + (PropertyKey::PrivateIdentifier(self.alloc(private_ident)), false) } + _ => self.parse_property_name(), } + } - let (key, computed) = - if let Some(result) = key_name { result } else { self.parse_class_element_name() }; + /// `ClassStaticBlockStatementList` : + /// `StatementList`[~Yield, +Await, ~Return] + fn parse_class_static_block(&mut self, span: u32) -> ClassElement<'a> { + self.bump_any(); // bump `static` + let block = + self.context(Context::Await, Context::Yield | Context::Return, Self::parse_block); + self.ast.class_element_static_block(self.end_span(span), block.unbox().body) + } - let (optional, optional_span) = if self.at(Kind::Question) { - let span = self.start_span(); - self.bump_any(); - (true, self.end_span(span)) + /// + fn parse_class_accessor_property( + &mut self, + span: u32, + key: PropertyKey<'a>, + computed: bool, + definite: bool, + modifiers: &Modifiers<'a>, + ) -> ClassElement<'a> { + let type_annotation = if self.is_ts { self.parse_ts_type_annotation() } else { None }; + let value = self.eat(Kind::Eq).then(|| self.parse_assignment_expression_or_higher()); + self.asi(); + let r#type = if modifiers.contains(ModifierKind::Abstract) { + AccessorPropertyType::TSAbstractAccessorProperty } else { - (false, oxc_span::SPAN) + AccessorPropertyType::AccessorProperty }; - let definite = self.eat(Kind::Bang); + self.verify_modifiers( + modifiers, + ModifierFlags::ACCESSIBILITY + | ModifierFlags::ACCESSOR + | ModifierFlags::STATIC + | ModifierFlags::ABSTRACT + | ModifierFlags::OVERRIDE, + diagnostics::accessor_modifier, + ); + self.ast.class_element_accessor_property( + self.end_span(span), + r#type, + self.consume_decorators(), + key, + type_annotation, + value, + computed, + modifiers.contains(ModifierKind::Static), + modifiers.contains(ModifierKind::Override), + definite, + modifiers.accessibility(), + ) + } - if optional && definite { - self.error(diagnostics::optional_definite_property(optional_span.expand_right(1))); - } + fn parse_accessor_declaration( + &mut self, + span: u32, + r#type: MethodDefinitionType, + kind: MethodDefinitionKind, + modifiers: &Modifiers<'a>, + ) -> ClassElement<'a> { + let (name, computed) = self.parse_class_element_name(modifiers); + let decorators = self.consume_decorators(); + let value = self.parse_method(modifiers.contains(ModifierKind::Async), false); + let method_definition = self.ast.alloc_method_definition( + self.end_span(span), + r#type, + decorators, + name, + value, + kind, + computed, + modifiers.contains(ModifierKind::Static), + modifiers.contains(ModifierKind::Override), + false, + modifiers.accessibility(), + ); + self.check_method_definition(&method_definition); + self.verify_modifiers( + modifiers, + ModifierFlags::all() - ModifierFlags::ASYNC, + diagnostics::modifier_cannot_be_used_here, + ); + ClassElement::MethodDefinition(method_definition) + } - if modifiers.contains(ModifierKind::Const) { - self.error(diagnostics::const_class_member(key.span())); - } + fn try_parse_constructor_declaration( + &mut self, + span: u32, + r#type: MethodDefinitionType, + modifiers: &Modifiers<'a>, + ) -> Option> { + let name = self.parse_constructor_name()?; + let decorators = self.consume_decorators(); + let value = self.parse_method(modifiers.contains(ModifierKind::Async), false); + let method_definition = self.ast.alloc_method_definition( + self.end_span(span), + r#type, + decorators, + name, + value, + MethodDefinitionKind::Constructor, + false, + modifiers.contains(ModifierKind::Static), + modifiers.contains(ModifierKind::Override), + false, + modifiers.accessibility(), + ); + self.check_method_definition(&method_definition); + Some(ClassElement::MethodDefinition(method_definition)) + } - if let PropertyKey::PrivateIdentifier(private_ident) = &key { - // `private #foo`, etc. is illegal - if self.is_ts { - self.verify_modifiers( - &modifiers, - ModifierFlags::all() - ModifierFlags::ACCESSIBILITY, - diagnostics::accessibility_modifier_on_private_property, - ); - } - if private_ident.name == "constructor" { - self.error(diagnostics::private_name_constructor(private_ident.span)); - } + fn parse_constructor_name(&mut self) -> Option> { + if self.at(Kind::Constructor) { + let ident = self.parse_identifier_name(); + return Some(PropertyKey::StaticIdentifier(self.alloc(ident))); } - - if accessor { - if optional { - self.error(diagnostics::optional_accessor_property(optional_span)); - } - Some( - self.parse_class_accessor_property( - span, key, computed, r#static, definite, &modifiers, - ), - ) - } else if self.at(Kind::LParen) || self.at(Kind::LAngle) || r#async || generator { - if !computed { - if let Some((name, span)) = key.prop_name() { - if r#static && name == "prototype" && !self.ctx.has_ambient() { - self.error(diagnostics::static_prototype(span)); - } - if !r#static && name == "constructor" { - if kind == MethodDefinitionKind::Get || kind == MethodDefinitionKind::Set { - self.error(diagnostics::constructor_getter_setter(span)); - } - if r#async { - self.error(diagnostics::constructor_async(span)); - } - if generator { - self.error(diagnostics::constructor_generator(span)); - } - } - } - } - // LAngle for start of type parameters `foo` - // ^ - let definition = self.parse_class_method_definition( - span, - kind, - key, - computed, - r#static, - r#async, - generator, - r#override, - r#abstract, - accessibility, - optional, - ); - Some(definition) - } else { - // getter and setter has no ts type annotation - if !kind.is_method() { - return self.unexpected(); - } - if !computed { - if let Some((name, span)) = key.prop_name() { - if name == "constructor" { - self.error(diagnostics::field_constructor(span)); - } - if r#static && name == "prototype" && !self.ctx.has_ambient() { - self.error(diagnostics::static_prototype(span)); - } + if self.at(Kind::Str) && self.peek_at(Kind::LParen) { + return self.try_parse(|p| { + let string_literal = p.parse_literal_string(); + if string_literal.value != "constructor" { + return p.unexpected(); } - } - let definition = self.parse_class_property_definition( - span, - key, - computed, - r#static, - declare, - r#override, - readonly, - r#abstract, - accessibility, - optional, - definite, - ); - Some(definition) + PropertyKey::StringLiteral(p.alloc(string_literal)) + }); } + None } - fn parse_class_element_name(&mut self) -> (PropertyKey<'a>, bool) { - match self.cur_kind() { - Kind::PrivateIdentifier => { - let private_ident = self.parse_private_identifier(); - (PropertyKey::PrivateIdentifier(self.alloc(private_ident)), false) + fn is_index_signature(&mut self) -> bool { + self.at(Kind::LBrack) && self.lookahead(Self::is_unambiguously_index_signature) + } + + fn is_unambiguously_index_signature(&mut self) -> bool { + self.bump_any(); + if matches!(self.cur_kind(), Kind::Dot3 | Kind::LBrack) { + return true; + } + if self.cur_kind().is_modifier_kind() { + self.bump_any(); + if self.cur_kind().is_identifier() { + return true; } - _ => self.parse_property_name(), + } else if !self.cur_kind().is_identifier() { + return false; + } else { + self.bump_any(); + } + if matches!(self.cur_kind(), Kind::Colon | Kind::Comma) { + return true; } + if self.cur_kind() != Kind::Question { + return false; + } + self.bump_any(); + matches!(self.cur_kind(), Kind::Colon | Kind::Comma | Kind::RBrack) } - fn parse_class_method_definition( + fn parse_property_or_method_declaration( &mut self, span: u32, - kind: MethodDefinitionKind, - key: PropertyKey<'a>, - computed: bool, - r#static: bool, - r#async: bool, - generator: bool, - r#override: bool, - r#abstract: bool, - accessibility: Option, - optional: bool, + r#type: MethodDefinitionType, + modifiers: &Modifiers<'a>, ) -> ClassElement<'a> { - let kind = if !r#static - && !computed - && key.prop_name().is_some_and(|(name, _)| name == "constructor") - { - MethodDefinitionKind::Constructor - } else { - kind - }; + let generator = self.eat(Kind::Star); + let (name, computed) = self.parse_class_element_name(modifiers); - let decorators = self.consume_decorators(); + let cur_token = self.cur_token(); + let optional_span = (cur_token.kind() == Kind::Question).then(|| { + let span = cur_token.span(); + self.bump_any(); + span + }); - let value = self.parse_method(r#async, generator); + let optional = optional_span.is_some(); - if kind == MethodDefinitionKind::Constructor { - if let Some(this_param) = &value.this_param { - // class Foo { constructor(this: number) {} } - self.error(diagnostics::ts_constructor_this_parameter(this_param.span)); - } + if generator || matches!(self.cur_kind(), Kind::LParen | Kind::LAngle) { + return self.parse_method_declaration( + span, r#type, generator, name, computed, optional, modifiers, + ); + } - if let Some(type_sig) = &value.type_parameters { - // class Foo { constructor(param: T ) {} } - self.error(diagnostics::ts_constructor_type_parameter(type_sig.span)); + let definite = self.eat(Kind::Bang); + + if definite { + if let Some(optional_span) = optional_span { + self.error(diagnostics::optional_definite_property(optional_span.expand_right(1))); } + } - if r#static { - self.error(diagnostics::static_constructor(key.span())); + if modifiers.contains(ModifierKind::Accessor) { + if let Some(optional_span) = optional_span { + self.error(diagnostics::optional_accessor_property(optional_span)); } + return self.parse_class_accessor_property(span, name, computed, definite, modifiers); } - let r#type = if r#abstract { - MethodDefinitionType::TSAbstractMethodDefinition - } else { - MethodDefinitionType::MethodDefinition - }; - self.ast.class_element_method_definition( + self.parse_property_declaration(span, name, computed, optional_span, definite, modifiers) + } + + fn parse_method_declaration( + &mut self, + span: u32, + r#type: MethodDefinitionType, + generator: bool, + name: PropertyKey<'a>, + computed: bool, + optional: bool, + modifiers: &Modifiers<'a>, + ) -> ClassElement<'a> { + let decorators = self.consume_decorators(); + let value = self.parse_method(modifiers.contains(ModifierKind::Async), generator); + let method_definition = self.ast.alloc_method_definition( self.end_span(span), r#type, decorators, - key, + name, value, - kind, + MethodDefinitionKind::Method, computed, - r#static, - r#override, + modifiers.contains(ModifierKind::Static), + modifiers.contains(ModifierKind::Override), optional, - accessibility, - ) + modifiers.accessibility(), + ); + self.check_method_definition(&method_definition); + ClassElement::MethodDefinition(method_definition) } - /// `FieldDefinition`[?Yield, ?Await] ; - fn parse_class_property_definition( + fn parse_property_declaration( &mut self, span: u32, - key: PropertyKey<'a>, + name: PropertyKey<'a>, computed: bool, - r#static: bool, - declare: bool, - r#override: bool, - readonly: bool, - r#abstract: bool, - accessibility: Option, - optional: bool, + optional_span: Option, definite: bool, + modifiers: &Modifiers, ) -> ClassElement<'a> { let type_annotation = if self.is_ts { self.parse_ts_type_annotation() } else { None }; let decorators = self.consume_decorators(); // Initializer[+In, ?Yield, ?Await]opt - let value = self + let initializer = self .eat(Kind::Eq) .then(|| self.context(Context::In, Context::Yield | Context::Await, Self::parse_expr)); - self.asi(); + // Handle trailing `;` or newline + let cur_token = self.cur_token(); + if cur_token.kind() == Kind::Semicolon { + self.bump_any(); + } else if !self.can_insert_semicolon() { + let error = diagnostics::expect_token(";", cur_token.kind().to_str(), cur_token.span()); + return self.fatal_error(error); + } + + let r#abstract = modifiers.contains(ModifierKind::Abstract); let r#type = if r#abstract { PropertyDefinitionType::TSAbstractPropertyDefinition } else { PropertyDefinitionType::PropertyDefinition }; + let r#static = modifiers.contains(ModifierKind::Static); + if !computed { + if let Some((name, span)) = name.prop_name() { + if name == "constructor" { + self.error(diagnostics::field_constructor(span)); + } + if r#static && name == "prototype" && !self.ctx.has_ambient() { + self.error(diagnostics::static_prototype(span)); + } + } + } self.ast.class_element_property_definition( self.end_span(span), r#type, decorators, - key, + name, type_annotation, - value, + initializer, computed, r#static, - declare, - r#override, - optional, + modifiers.contains(ModifierKind::Declare), + modifiers.contains(ModifierKind::Override), + optional_span.is_some(), definite, - readonly, - accessibility, + modifiers.contains(ModifierKind::Readonly), + modifiers.accessibility(), ) } - /// `ClassStaticBlockStatementList` : - /// `StatementList`[~Yield, +Await, ~Return] - fn parse_class_static_block(&mut self, span: u32) -> ClassElement<'a> { - let block = - self.context(Context::Await, Context::Yield | Context::Return, Self::parse_block); - self.ast.class_element_static_block(self.end_span(span), block.unbox().body) - } + fn check_method_definition(&mut self, method: &MethodDefinition<'a>) { + if !method.computed { + if let Some((name, span)) = method.key.prop_name() { + if method.r#static && name == "prototype" && !self.ctx.has_ambient() { + self.error(diagnostics::static_prototype(span)); + } + if !method.r#static && name == "constructor" { + if method.kind == MethodDefinitionKind::Get + || method.kind == MethodDefinitionKind::Set + { + self.error(diagnostics::constructor_getter_setter(span)); + } + if method.value.r#async { + self.error(diagnostics::constructor_async(span)); + } + if method.value.generator { + self.error(diagnostics::constructor_generator(span)); + } + } + } + } + if method.kind == MethodDefinitionKind::Constructor { + if let Some(this_param) = &method.value.this_param { + // class Foo { constructor(this: number) {} } + self.error(diagnostics::ts_constructor_this_parameter(this_param.span)); + } - /// - fn parse_class_accessor_property( - &mut self, - span: u32, - key: PropertyKey<'a>, - computed: bool, - r#static: bool, - definite: bool, - modifiers: &Modifiers<'a>, - ) -> ClassElement<'a> { - let type_annotation = if self.is_ts { self.parse_ts_type_annotation() } else { None }; - let value = self.eat(Kind::Eq).then(|| self.parse_assignment_expression_or_higher()); - self.asi(); - let r#type = if modifiers.contains(ModifierKind::Abstract) { - AccessorPropertyType::TSAbstractAccessorProperty - } else { - AccessorPropertyType::AccessorProperty - }; - self.verify_modifiers( - modifiers, - ModifierFlags::ACCESSIBILITY - | ModifierFlags::ACCESSOR - | ModifierFlags::STATIC - | ModifierFlags::ABSTRACT - | ModifierFlags::OVERRIDE, - diagnostics::accessor_modifier, - ); - self.ast.class_element_accessor_property( - self.end_span(span), - r#type, - self.consume_decorators(), - key, - type_annotation, - value, - computed, - r#static, - modifiers.contains(ModifierKind::Override), - definite, - modifiers.accessibility(), - ) + if let Some(type_sig) = &method.value.type_parameters { + // class Foo { constructor(param: T ) {} } + self.error(diagnostics::ts_constructor_type_parameter(type_sig.span)); + } + } } } diff --git a/crates/oxc_parser/src/modifiers.rs b/crates/oxc_parser/src/modifiers.rs index 4d29074da5c63..f110183ead224 100644 --- a/crates/oxc_parser/src/modifiers.rs +++ b/crates/oxc_parser/src/modifiers.rs @@ -102,12 +102,14 @@ pub struct Modifier { pub span: Span, pub kind: ModifierKind, } + impl Modifier { #[inline] pub fn is_static(&self) -> bool { matches!(self.kind, ModifierKind::Static) } } + impl TryFrom for Modifier { type Error = >::Error; @@ -450,7 +452,7 @@ impl<'a> ParserImpl<'a> { && self.try_parse(Self::next_token_can_follow_modifier).is_some() } - fn next_token_can_follow_modifier(&mut self) { + pub(crate) fn next_token_can_follow_modifier(&mut self) { let b = match self.cur_kind() { Kind::Const => self.peek_at(Kind::Enum), Kind::Export => { @@ -462,10 +464,14 @@ impl<'a> ParserImpl<'a> { } } Kind::Default => self.next_token_can_follow_default_keyword(), - Kind::Static | Kind::Get | Kind::Set => { + Kind::Static => { self.bump_any(); self.can_follow_modifier() } + Kind::Get | Kind::Set => { + self.bump_any(); + self.can_follow_get_or_set_keyword() + } _ => self.next_token_is_on_same_line_and_can_follow_modifier(), }; if !b { @@ -522,6 +528,11 @@ impl<'a> ParserImpl<'a> { } } + fn can_follow_get_or_set_keyword(&self) -> bool { + let kind = self.cur_kind(); + kind == Kind::LBrack || kind == Kind::PrivateIdentifier || kind.is_literal_property_name() + } + fn next_token_is_class_keyword_on_same_line(&mut self) -> bool { self.bump_any(); self.cur_kind() == Kind::Class && !self.cur_token().is_on_new_line() diff --git a/tasks/coverage/snapshots/parser_babel.snap b/tasks/coverage/snapshots/parser_babel.snap index cefbbce2fc167..d872581e6ed67 100644 --- a/tasks/coverage/snapshots/parser_babel.snap +++ b/tasks/coverage/snapshots/parser_babel.snap @@ -3,7 +3,7 @@ commit: 578ac4df parser_babel Summary: AST Parsed : 2309/2322 (99.44%) Positive Passed: 2288/2322 (98.54%) -Negative Passed: 1560/1673 (93.25%) +Negative Passed: 1561/1673 (93.31%) Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/core/categorized/invalid-startindex-and-startline-specified-without-startcolumn/input.js Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/core/categorized/startline-and-startcolumn-specified/input.js @@ -40,8 +40,6 @@ Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/esprima/es2015-generator/generator-parameter-binding-property-reserved/input.js -Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0276/input.js - Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/class-private-property/typescript-invalid-abstract/input.ts Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/class-private-property/typescript-invalid-abstract-babel-7/input.ts @@ -2934,41 +2932,41 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc 3 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-async-identifier/input.js:2:10] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-async-identifier/input.js:2:11] 1 │ class A { 2 │ [async] a() {} - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-async-string/input.js:2:12] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-async-string/input.js:2:13] 1 │ class A { 2 │ ["async"] a() {} - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-get-identifier/input.js:2:8] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-get-identifier/input.js:2:9] 1 │ class A { 2 │ [get] a() {} - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-get-string/input.js:2:10] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-computed-get-string/input.js:2:11] 1 │ class A { 2 │ ["get"] a() {} - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × Identifier `a` has already been declared ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/input.js:2:9] @@ -2980,23 +2978,23 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc 3 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-literal-async/input.js:2:10] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-literal-async/input.js:2:11] 1 │ class A { 2 │ "async" a() {} - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-literal-get/input.js:2:8] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-literal-get/input.js:2:9] 1 │ class A { 2 │ "get" a() {} - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × Classes may not have a static property named prototype ╭─[babel/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-generator-prototype/input.js:2:11] @@ -8121,23 +8119,23 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc 4 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-private-properties/asi-failure-generator/input.js:3:8] + × Expected `;` but found `{` + ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-private-properties/asi-failure-generator/input.js:3:9] 2 │ #p = x 3 │ *m () {} - · ▲ + · ┬ + · ╰── `;` expected 4 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-private-properties/asi-failure-inline/input.js:2:5] + × Expected `;` but found `#identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-private-properties/asi-failure-inline/input.js:2:6] 1 │ class Foo { 2 │ #x #y - · ▲ + · ─┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × Invalid Character `[` ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-private-properties/failure-computed/input.js:3:4] @@ -8297,32 +8295,32 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc 4 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/asi-failure-computed/input.js:3:9] + × Expected `;` but found `{` + ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/asi-failure-computed/input.js:3:10] 2 │ p = x 3 │ [m] () {} - · ▲ + · ┬ + · ╰── `;` expected 4 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/asi-failure-generator/input.js:3:8] + × Expected `;` but found `{` + ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/asi-failure-generator/input.js:3:9] 2 │ p = x 3 │ *m () {} - · ▲ + · ┬ + · ╰── `;` expected 4 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/asi-failure-inline/input.js:2:4] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/asi-failure-inline/input.js:2:5] 1 │ class Foo { 2 │ x y - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/await-in-computed-property-in-params-of-async-arrow/input.js:1:34] @@ -8338,20 +8336,21 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc ╰──── help: new.target is only allowed in constructors and functions invoked using thew `new` operator - × Classes can't have a field named 'constructor' - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/no-ctor/input.js:2:3] - 1 │ class Foo { + × Expected `(` but found `}` + ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/no-ctor/input.js:3:1] 2 │ constructor - · ─────────── 3 │ } + · ┬ + · ╰── `(` expected ╰──── - × Classes can't have a field named 'constructor' - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/no-ctor-2/input.js:2:3] - 1 │ class Foo { + × Expected `(` but found `*` + ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/no-ctor-2/input.js:3:3] 2 │ constructor - · ─────────── 3 │ *x(){} + · ┬ + · ╰── `(` expected + 4 │ } ╰──── × Classes may not have a static property named prototype @@ -11342,12 +11341,12 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc · ╰── `{` expected ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none + × Expected `;` but found `:` ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0268/input.js:1:11] 1 │ class A {a:0} - · ▲ + · ┬ + · ╰── `;` expected ╰──── - help: Try insert a semicolon here × Unexpected token ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0269/input.js:1:15] @@ -11387,12 +11386,19 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc · ╰── constructor has already been declared here ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0275/input.js:1:11] + × Expected `;` but found `static` + ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0275/input.js:1:12] 1 │ class A {a static(){}} - · ▲ + · ───┬── + · ╰── `;` expected + ╰──── + + × Expected `;` but found `static` + ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0276/input.js:1:24] + 1 │ class A {static static static(){}} + · ───┬── + · ╰── `;` expected ╰──── - help: Try insert a semicolon here × Identifier expected. 'enum' is a reserved word that cannot be used here. ╭─[babel/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0277/input.js:1:12] @@ -12114,14 +12120,14 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc 4 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[babel/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/input.js:3:11] + × Expected `;` but found `Identifier` + ╭─[babel/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/input.js:3:12] 2 │ class A extends B { 3 │ async? method(val: string): Promise; - · ▲ + · ───┬── + · ╰── `;` expected 4 │ } ╰──── - help: Try insert a semicolon here × A parameter property is only allowed in a constructor implementation. ╭─[babel/packages/babel-parser/test/fixtures/typescript/class/parameter-properties-not-constructor/input.ts:3:9] diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 1ea5ede2a4341..1a91a2715ae42 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -35,19 +35,21 @@ Negative Passed: 34/34 (100.00%) 1 │ 1<(V=82< ╰──── - × Unexpected token + × Expected `(` but found `:` ╭─[misc/fail/oxc-1942-1.ts:2:8] 1 │ class Foo { 2 │ get x: () => { - · ─ + · ┬ + · ╰── `(` expected 3 │ return 5; ╰──── - × Unexpected token + × Expected `(` but found `:` ╭─[misc/fail/oxc-1942-2.ts:2:8] 1 │ class Foo { 2 │ set x: (v: number) => {} - · ─ + · ┬ + · ╰── `(` expected 3 │ } ╰──── @@ -194,18 +196,18 @@ Negative Passed: 34/34 (100.00%) help: Try insert a semicolon here × TS(1248): A class member cannot have the 'const' keyword. - ╭─[misc/fail/oxc-4212-1.ts:1:17] + ╭─[misc/fail/oxc-4212-1.ts:1:11] 1 │ class a { const enum b(); } - · ──── + · ───── ╰──── help: Did you mean `readonly`? - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[misc/fail/oxc-4212-1.ts:1:21] + × Expected `;` but found `Identifier` + ╭─[misc/fail/oxc-4212-1.ts:1:22] 1 │ class a { const enum b(); } - · ▲ + · ┬ + · ╰── `;` expected ╰──── - help: Try insert a semicolon here × TS(1164): Computed property names are not allowed in enums. ╭─[misc/fail/oxc-4449-1.ts:1:11] diff --git a/tasks/coverage/snapshots/parser_test262.snap b/tasks/coverage/snapshots/parser_test262.snap index 822f8e7871067..c36daf5a6ac7d 100644 --- a/tasks/coverage/snapshots/parser_test262.snap +++ b/tasks/coverage/snapshots/parser_test262.snap @@ -10324,41 +10324,41 @@ Negative Passed: 4519/4519 (100.00%) 28 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/fields-asi-3.js:18:8] + × Expected `;` but found `{` + ╭─[test262/test/language/expressions/class/elements/fields-asi-3.js:18:9] 17 │ x = "string" 18 │ [0]() {} - · ▲ + · ┬ + · ╰── `;` expected 19 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/fields-asi-4.js:18:9] + × Expected `;` but found `{` + ╭─[test262/test/language/expressions/class/elements/fields-asi-4.js:18:10] 17 │ x = 42 18 │ *gen() {} - · ▲ + · ┬ + · ╰── `;` expected 19 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/fields-asi-same-line-1.js:17:8] + × Expected `;` but found `Identifier` + ╭─[test262/test/language/expressions/class/elements/fields-asi-same-line-1.js:17:27] 16 │ var C = class { 17 │ field /* no ASI here */ method(){} - · ▲ + · ───┬── + · ╰── `;` expected 18 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/fields-asi-same-line-2.js:17:12] + × Expected `;` but found `Identifier` + ╭─[test262/test/language/expressions/class/elements/fields-asi-same-line-2.js:17:31] 16 │ var C = class { 17 │ field = 1 /* no ASI here */ method(){} - · ▲ + · ───┬── + · ╰── `;` expected 18 │ } ╰──── - help: Try insert a semicolon here × Identifier `x` has already been declared ╭─[test262/test/language/expressions/class/elements/fields-duplicate-privatenames.js:23:3] @@ -10372,11 +10372,12 @@ Negative Passed: 4519/4519 (100.00%) 25 │ } ╰──── - × Classes can't have a field named 'constructor' - ╭─[test262/test/language/expressions/class/elements/fields-literal-name-propname-constructor.js:29:3] + × Expected `(` but found `;` + ╭─[test262/test/language/expressions/class/elements/fields-literal-name-propname-constructor.js:29:14] 28 │ var C = class { 29 │ constructor; - · ─────────── + · ┬ + · ╰── `(` expected 30 │ }; ╰──── @@ -10680,23 +10681,23 @@ Negative Passed: 4519/4519 (100.00%) 28 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/nested-equality-init-err-contains-arguments.js:33:15] + × Expected `;` but found `==` + ╭─[test262/test/language/expressions/class/elements/nested-equality-init-err-contains-arguments.js:33:16] 32 │ var C = class { 33 │ x = () => {} == arguments; - · ▲ + · ─┬ + · ╰── `;` expected 34 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/nested-equality-init-err-contains-super.js:26:15] + × Expected `;` but found `==` + ╭─[test262/test/language/expressions/class/elements/nested-equality-init-err-contains-super.js:26:16] 25 │ var C = class { 26 │ x = () => {} == super(); - · ▲ + · ─┬ + · ╰── `;` expected 27 │ } ╰──── - help: Try insert a semicolon here × 'arguments' is not allowed in class field initializer ╭─[test262/test/language/expressions/class/elements/nested-literal-name-init-err-contains-arguments.js:33:13] @@ -12396,14 +12397,14 @@ Negative Passed: 4519/4519 (100.00%) 71 │ }; ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/syntax/early-errors/grammar-fields-same-line-error.js:33:4] + × Expected `;` but found `Identifier` + ╭─[test262/test/language/expressions/class/elements/syntax/early-errors/grammar-fields-same-line-error.js:33:5] 32 │ var C = class { 33 │ x y - · ▲ + · ┬ + · ╰── `;` expected 34 │ }; ╰──── - help: Try insert a semicolon here × Expected `{` but found `=>` ╭─[test262/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js:37:27] @@ -12843,14 +12844,14 @@ Negative Passed: 4519/4519 (100.00%) 30 │ }; ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/expressions/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js:36:5] + × Expected `;` but found `#identifier` + ╭─[test262/test/language/expressions/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js:36:6] 35 │ var C = class { 36 │ #x #y - · ▲ + · ─┬ + · ╰── `;` expected 37 │ }; ╰──── - help: Try insert a semicolon here × Super calls are not permitted outside constructors or in nested functions inside constructors. ╭─[test262/test/language/expressions/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async-gen.js:26:7] @@ -26977,12 +26978,12 @@ Negative Passed: 4519/4519 (100.00%) 17 │ } ╰──── - × Expected `(` but found `Identifier` + × Expected `;` but found `Identifier` ╭─[test262/test/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js:18:18] 17 │ class Foo { 18 │ async function foo(bar) { let bar; } · ─┬─ - · ╰── `(` expected + · ╰── `;` expected 19 │ } ╰──── @@ -28727,41 +28728,41 @@ Negative Passed: 4519/4519 (100.00%) 28 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/fields-asi-3.js:18:8] + × Expected `;` but found `{` + ╭─[test262/test/language/statements/class/elements/fields-asi-3.js:18:9] 17 │ x = "string" 18 │ [0]() {} - · ▲ + · ┬ + · ╰── `;` expected 19 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/fields-asi-4.js:18:9] + × Expected `;` but found `{` + ╭─[test262/test/language/statements/class/elements/fields-asi-4.js:18:10] 17 │ x = 42 18 │ *gen() {} - · ▲ + · ┬ + · ╰── `;` expected 19 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/fields-asi-same-line-1.js:17:8] + × Expected `;` but found `Identifier` + ╭─[test262/test/language/statements/class/elements/fields-asi-same-line-1.js:17:27] 16 │ class C { 17 │ field /* no ASI here */ method(){} - · ▲ + · ───┬── + · ╰── `;` expected 18 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/fields-asi-same-line-2.js:17:12] + × Expected `;` but found `Identifier` + ╭─[test262/test/language/statements/class/elements/fields-asi-same-line-2.js:17:31] 16 │ class C { 17 │ field = 1 /* no ASI here */ method(){} - · ▲ + · ───┬── + · ╰── `;` expected 18 │ } ╰──── - help: Try insert a semicolon here × Identifier `x` has already been declared ╭─[test262/test/language/statements/class/elements/fields-duplicate-privatenames.js:23:3] @@ -28775,11 +28776,12 @@ Negative Passed: 4519/4519 (100.00%) 25 │ } ╰──── - × Classes can't have a field named 'constructor' - ╭─[test262/test/language/statements/class/elements/fields-literal-name-propname-constructor.js:29:3] + × Expected `(` but found `;` + ╭─[test262/test/language/statements/class/elements/fields-literal-name-propname-constructor.js:29:14] 28 │ class C { 29 │ constructor; - · ─────────── + · ┬ + · ╰── `(` expected 30 │ } ╰──── @@ -29083,23 +29085,23 @@ Negative Passed: 4519/4519 (100.00%) 28 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/nested-equality-init-err-contains-arguments.js:33:15] + × Expected `;` but found `==` + ╭─[test262/test/language/statements/class/elements/nested-equality-init-err-contains-arguments.js:33:16] 32 │ class C { 33 │ x = () => {} == arguments; - · ▲ + · ─┬ + · ╰── `;` expected 34 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/nested-equality-init-err-contains-super.js:26:15] + × Expected `;` but found `==` + ╭─[test262/test/language/statements/class/elements/nested-equality-init-err-contains-super.js:26:16] 25 │ class C { 26 │ x = () => {} == super(); - · ▲ + · ─┬ + · ╰── `;` expected 27 │ } ╰──── - help: Try insert a semicolon here × 'arguments' is not allowed in class field initializer ╭─[test262/test/language/statements/class/elements/nested-literal-name-init-err-contains-arguments.js:33:13] @@ -30860,14 +30862,14 @@ Negative Passed: 4519/4519 (100.00%) 71 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/syntax/early-errors/grammar-fields-same-line-error.js:33:4] + × Expected `;` but found `Identifier` + ╭─[test262/test/language/statements/class/elements/syntax/early-errors/grammar-fields-same-line-error.js:33:5] 32 │ class C { 33 │ x y - · ▲ + · ┬ + · ╰── `;` expected 34 │ } ╰──── - help: Try insert a semicolon here × Expected `{` but found `=>` ╭─[test262/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js:37:21] @@ -31307,14 +31309,14 @@ Negative Passed: 4519/4519 (100.00%) 30 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[test262/test/language/statements/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js:36:5] + × Expected `;` but found `#identifier` + ╭─[test262/test/language/statements/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js:36:6] 35 │ class C { 36 │ #x #y - · ▲ + · ─┬ + · ╰── `;` expected 37 │ } ╰──── - help: Try insert a semicolon here × Super calls are not permitted outside constructors or in nested functions inside constructors. ╭─[test262/test/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async-gen.js:26:7] diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index f93492027c1c9..5161c953cda9f 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -3,7 +3,7 @@ commit: 15392346 parser_typescript Summary: AST Parsed : 6521/6528 (99.89%) Positive Passed: 6509/6528 (99.71%) -Negative Passed: 1315/5757 (22.84%) +Negative Passed: 1323/5757 (22.98%) Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ClassDeclaration24.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ExportAssignment7.ts @@ -3742,8 +3742,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/spreadOfPara Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/spyComparisonChecking.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticAsIdentifier.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticClassMemberError.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticInstanceResolution4.ts @@ -3760,8 +3758,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticMethod Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticMismatchBecauseOfPrototype.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticModifierAlreadySeen.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticMustPrecedePublic.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticOffOfInstance1.ts @@ -5344,10 +5340,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/es6/compu Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts - -Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES5.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES6.ts @@ -7486,8 +7478,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ec Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/Generics/parserObjectCreation1.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration5.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts @@ -7512,18 +7502,12 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ec Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration3.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration8.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration9.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration2.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration3.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration2.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration3.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration1.d.ts @@ -9302,22 +9286,22 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── × TS(1248): A class member cannot have the 'const' keyword. - ╭─[typescript/tests/cases/compiler/ClassDeclaration26.ts:2:18] + ╭─[typescript/tests/cases/compiler/ClassDeclaration26.ts:2:12] 1 │ class C { 2 │ public const var export foo = 10; - · ─── + · ───── 3 │ ╰──── help: Did you mean `readonly`? - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/compiler/ClassDeclaration26.ts:2:21] + × Expected `;` but found `export` + ╭─[typescript/tests/cases/compiler/ClassDeclaration26.ts:2:22] 1 │ class C { 2 │ public const var export foo = 10; - · ▲ + · ───┬── + · ╰── `;` expected 3 │ ╰──── - help: Try insert a semicolon here × Constructor implementation is missing. ╭─[typescript/tests/cases/compiler/ClassDeclaration8.ts:2:3] @@ -9336,10 +9320,10 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── × TS(1248): A class member cannot have the 'const' keyword. - ╭─[typescript/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts:2:16] + ╭─[typescript/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts:2:10] 1 │ class AtomicNumbers { 2 │ static const H = 1; - · ─ + · ───── 3 │ } ╰──── help: Did you mean `readonly`? @@ -9565,14 +9549,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private · ─ ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none + × Expected `;` but found `:` ╭─[typescript/tests/cases/compiler/ambientPropertyDeclarationInJs.ts:6:17] 5 │ 6 │ declare prop: string; - · ▲ + · ┬ + · ╰── `;` expected 7 │ ╰──── - help: Try insert a semicolon here × TS(1108): A 'return' statement can only be used within a function body. ╭─[typescript/tests/cases/compiler/ambientWithStatements.ts:11:5] @@ -10351,21 +10335,21 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 4 │ constructor() { ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/compiler/classExpressionPropertyModifiers.ts:3:11] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/compiler/classExpressionPropertyModifiers.ts:3:12] 2 │ declare [Symbol.toStringTag] = "uh"; 3 │ export foo = 1; - · ▲ + · ─┬─ + · ╰── `;` expected 4 │ } ╰──── - help: Try insert a semicolon here - × Classes can't have a field named 'constructor' - ╭─[typescript/tests/cases/compiler/classFieldsBrokenConstructorEmitNoCrash1.ts:3:3] - 2 │ prop = 42; + × Expected `(` but found `}` + ╭─[typescript/tests/cases/compiler/classFieldsBrokenConstructorEmitNoCrash1.ts:4:1] 3 │ constructor - · ─────────── 4 │ } + · ┬ + · ╰── `(` expected ╰──── × Expected `{` but found `EOF` @@ -11354,10 +11338,10 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── × TS(1248): A class member cannot have the 'const' keyword. - ╭─[typescript/tests/cases/compiler/constInClassExpression.ts:2:11] + ╭─[typescript/tests/cases/compiler/constInClassExpression.ts:2:5] 1 │ let C = class { 2 │ const a = 4; - · ─ + · ───── 3 │ }; ╰──── help: Did you mean `readonly`? @@ -12847,14 +12831,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 2 │ ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/compiler/illegalModifiersOnClassElements.ts:3:11] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/compiler/illegalModifiersOnClassElements.ts:3:12] 2 │ declare foo = 1; 3 │ export bar = 1; - · ▲ + · ─┬─ + · ╰── `;` expected 4 │ } ╰──── - help: Try insert a semicolon here × Super calls are not permitted outside constructors or in nested functions inside constructors. ╭─[typescript/tests/cases/compiler/illegalSuperCallsInConstructor.ts:9:32] @@ -14445,6 +14429,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Remove the duplicate modifier. + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/compiler/multipleClassPropertyModifiersErrors.ts:4:16] + 3 │ private private p2; + 4 │ static static p3; + · ─┬ + · ╰── `;` expected + 5 │ public private p4; + ╰──── + × Identifier `x` has already been declared ╭─[typescript/tests/cases/compiler/nameCollisions.ts:2:9] 1 │ module T { @@ -14484,14 +14477,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 26 │ ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/compiler/nestedGlobalNamespaceInClass.ts:3:11] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/compiler/nestedGlobalNamespaceInClass.ts:3:12] 2 │ class C { 3 │ global x - · ▲ + · ┬ + · ╰── `;` expected 4 │ } ╰──── - help: Try insert a semicolon here × Unexpected token ╭─[typescript/tests/cases/compiler/nestedUnaryExpressionHang.ts:1:34] @@ -15652,14 +15645,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 5 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/compiler/propertyWrappedInTry.ts:3:8] + × Expected `;` but found `{` + ╭─[typescript/tests/cases/compiler/propertyWrappedInTry.ts:3:9] 2 │ 3 │ try { - · ▲ + · ┬ + · ╰── `;` expected 4 │ ╰──── - help: Try insert a semicolon here × A parameter property is only allowed in a constructor implementation. ╭─[typescript/tests/cases/compiler/readonlyInNonPropertyParameters.ts:3:9] @@ -16425,6 +16418,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: A `break` statement can only be used within an enclosing iteration or switch statement. + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/compiler/staticAsIdentifier.ts:12:19] + 11 │ class C3 { + 12 │ static static p: string; + · ┬ + · ╰── `;` expected + 13 │ } + ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[typescript/tests/cases/compiler/staticClassProps.ts:4:15] 3 │ public foo() { @@ -16434,6 +16436,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Try insert a semicolon here + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/compiler/staticModifierAlreadySeen.ts:2:19] + 1 │ class C { + 2 │ static static foo = 1; + · ─┬─ + · ╰── `;` expected + 3 │ public static static bar() { } + ╰──── + × Classes may not have a static property named prototype ╭─[typescript/tests/cases/compiler/staticPrototypeProperty.ts:2:11] 1 │ class C { @@ -18365,12 +18376,11 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 2 │ Value ╰──── - × Expected `(` but found `Identifier` - ╭─[typescript/tests/cases/conformance/async/es5/asyncGetter_es5.ts:2:13] + × 'async' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/async/es5/asyncGetter_es5.ts:2:3] 1 │ class C { 2 │ async get foo() { - · ─┬─ - · ╰── `(` expected + · ───── 3 │ } ╰──── @@ -18395,12 +18405,11 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 2 │ } ╰──── - × Expected `(` but found `Identifier` - ╭─[typescript/tests/cases/conformance/async/es5/asyncSetter_es5.ts:2:13] + × 'async' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/async/es5/asyncSetter_es5.ts:2:3] 1 │ class C { 2 │ async set foo(value) { - · ─┬─ - · ╰── `(` expected + · ───── 3 │ } ╰──── @@ -18507,12 +18516,11 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 2 │ Value ╰──── - × Expected `(` but found `Identifier` - ╭─[typescript/tests/cases/conformance/async/es6/asyncGetter_es6.ts:2:13] + × 'async' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/async/es6/asyncGetter_es6.ts:2:3] 1 │ class C { 2 │ async get foo() { - · ─┬─ - · ╰── `(` expected + · ───── 3 │ } ╰──── @@ -18537,12 +18545,11 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 2 │ } ╰──── - × Expected `(` but found `Identifier` - ╭─[typescript/tests/cases/conformance/async/es6/asyncSetter_es6.ts:2:13] + × 'async' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/async/es6/asyncSetter_es6.ts:2:3] 1 │ class C { 2 │ async set foo(value) { - · ─┬─ - · ╰── `(` expected + · ───── 3 │ } ╰──── @@ -18925,14 +18932,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 10 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/classes/classDeclarations/classBody/classBodyWithStatements.ts:2:8] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/classes/classDeclarations/classBody/classBodyWithStatements.ts:2:9] 1 │ class C { 2 │ var x = 1; - · ▲ + · ┬ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × Expected `{` but found `?.` ╭─[typescript/tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingOptionalChain.ts:9:22] @@ -19261,14 +19268,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 25 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none + × Expected `;` but found `(` ╭─[typescript/tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts:8:13] 7 │ class Derived extends Base { 8 │ a: super(); - · ▲ + · ┬ + · ╰── `;` expected 9 │ b() { ╰──── - help: Try insert a semicolon here × 'super' can only be referenced in a derived class. ╭─[typescript/tests/cases/conformance/classes/constructorDeclarations/superCalls/superCallInConstructorWithNoBaseType.ts:1:1] @@ -19353,14 +19360,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 13 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none + × Expected `;` but found `.` ╭─[typescript/tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts:12:12] 11 │ 12 │ a: this.foo; // error - · ▲ + · ┬ + · ╰── `;` expected 13 │ } ╰──── - help: Try insert a semicolon here × Super calls are not permitted outside constructors or in nested functions inside constructors. ╭─[typescript/tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers6.ts:6:16] @@ -20230,15 +20237,46 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 23 │ readonly get #quxProp() { return 3; } // Error ╰──── - × Expected `(` but found `#identifier` - ╭─[typescript/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:27:15] + × 'async' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:27:5] 26 │ declare set #whatProp(value: number) // Error 27 │ async get #asyncProp() { return 1; } // Error - · ─────┬──── - · ╰── `(` expected + · ───── 28 │ async set #asyncProp(value: number) { } // Error ╰──── + × 'async' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:28:5] + 27 │ async get #asyncProp() { return 1; } // Error + 28 │ async set #asyncProp(value: number) { } // Error + · ───── + 29 │ } + ╰──── + + × Getters and setters must have an implementation. + ╭─[typescript/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:25:17] + 24 │ readonly set #quxProp(value: number) { } // Error + 25 │ declare get #whatProp() // Error + · ───────── + 26 │ declare set #whatProp(value: number) // Error + ╰──── + + × Getters and setters must have an implementation. + ╭─[typescript/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:26:17] + 25 │ declare get #whatProp() // Error + 26 │ declare set #whatProp(value: number) // Error + · ───────── + 27 │ async get #asyncProp() { return 1; } // Error + ╰──── + + × TS(1267): Property '#quux' cannot have an initializer because it is marked abstract. + ╭─[typescript/tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiers.ts:32:14] + 31 │ abstract class B { + 32 │ abstract #quux = 3; // Error + · ───── + 33 │ } + ╰──── + × Private identifier '#prop' is not allowed outside class bodies ╭─[typescript/tests/cases/conformance/classes/members/privateNames/privateNamesInterfaceExtendingClass.ts:10:7] 9 │ function func(x: I) { @@ -20269,14 +20307,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private · ──── ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/classes/nestedClassDeclaration.ts:5:10] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/classes/nestedClassDeclaration.ts:5:11] 4 │ x: string; 5 │ class C2 { - · ▲ + · ─┬ + · ╰── `;` expected 6 │ } ╰──── - help: Try insert a semicolon here × TS(1267): Property 'prop' cannot have an initializer because it is marked abstract. ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/abstractPropertyInitializer.ts:2:14] @@ -20343,14 +20381,101 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 5 │ accessor public d: any; ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:10:15] - 9 │ accessor static h: any; - 10 │ accessor i() {} - · ▲ - 11 │ accessor get j() { return false; } + × TS(1276): An 'accessor' property cannot be declared optional. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:14:15] + 13 │ accessor constructor() {} + 14 │ accessor l?: any; + · ─ + 15 │ accessor readonly m: any; + ╰──── + + × TS(1243): 'accessor' modifier cannot be used with 'readonly' modifier. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:15:14] + 14 │ accessor l?: any; + 15 │ accessor readonly m: any; + · ──────── + 16 │ accessor declare n: any; + ╰──── + + × TS(1243): 'accessor' modifier cannot be used with 'declare' modifier. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:16:14] + 15 │ accessor readonly m: any; + 16 │ accessor declare n: any; + · ─────── + 17 │ } + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:27:1] + 26 │ + 27 │ accessor class C3 {} + · ──────── + 28 │ accessor interface I2 {} + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:28:1] + 27 │ accessor class C3 {} + 28 │ accessor interface I2 {} + · ──────── + 29 │ accessor namespace N1 {} + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:29:1] + 28 │ accessor interface I2 {} + 29 │ accessor namespace N1 {} + · ──────── + 30 │ accessor enum E1 {} + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:29:1] + 28 │ accessor interface I2 {} + 29 │ accessor namespace N1 {} + · ──────── + 30 │ accessor enum E1 {} + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:30:1] + 29 │ accessor namespace N1 {} + 30 │ accessor enum E1 {} + · ──────── + 31 │ accessor var V1: any; + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:31:1] + 30 │ accessor enum E1 {} + 31 │ accessor var V1: any; + · ──────── + 32 │ accessor type T1 = never; + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:32:1] + 31 │ accessor var V1: any; + 32 │ accessor type T1 = never; + · ──────── + 33 │ accessor function F1() {} + ╰──── + + × 'accessor' modifier cannot be used here. + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:33:1] + 32 │ accessor type T1 = never; + 33 │ accessor function F1() {} + · ──────── + 34 │ accessor import "x"; + ╰──── + + × Unexpected token + ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorDisallowedModifiers.ts:34:17] + 33 │ accessor function F1() {} + 34 │ accessor import "x"; + · ─── + 35 │ accessor import {} from "x"; ╰──── - help: Try insert a semicolon here × Expected `,` but found `*` ╭─[typescript/tests/cases/conformance/classes/propertyMemberDeclarations/canFollowGetSetKeyword.ts:11:5] @@ -20559,23 +20684,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 3 │ ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts:4:11] + × Expected `;` but found `@` + ╭─[typescript/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts:4:12] 3 │ class C { 4 │ public @dec get accessor() { return 1; } - · ▲ + · ┬ + · ╰── `;` expected 5 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts:4:11] + × Expected `;` but found `@` + ╭─[typescript/tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts:4:12] 3 │ class C { 4 │ public @dec set accessor(value: number) { } - · ▲ + · ┬ + · ╰── `;` expected 5 │ } ╰──── - help: Try insert a semicolon here × Expected `,` but found `@` ╭─[typescript/tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts:4:24] @@ -20586,23 +20711,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 5 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod17.ts:4:17] + × Expected `;` but found `@` + ╭─[typescript/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod17.ts:4:18] 3 │ class Foo { 4 │ private prop @decorator - · ▲ + · ┬ + · ╰── `;` expected 5 │ foo() { ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts:4:11] + × Expected `;` but found `@` + ╭─[typescript/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts:4:12] 3 │ class C { 4 │ public @dec method() {} - · ▲ + · ┬ + · ╰── `;` expected 5 │ } ╰──── - help: Try insert a semicolon here × await expression not allowed in formal parameter ╭─[typescript/tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter3.ts:5:23] @@ -20621,14 +20746,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 5 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts:4:11] + × Expected `;` but found `@` + ╭─[typescript/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts:4:12] 3 │ class C { 4 │ public @dec prop; - · ▲ + · ┬ + · ╰── `;` expected 5 │ } ╰──── - help: Try insert a semicolon here × Unexpected token ╭─[typescript/tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts:9:9] @@ -20940,6 +21065,22 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: either remove this super, or extend the class + × Unexpected token + ╭─[typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts:5:6] + 4 │ static [true]() { } + 5 │ [[]]() { } + · ─ + 6 │ static [{}]() { } + ╰──── + + × Unexpected token + ╭─[typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts:5:6] + 4 │ static [true]() { } + 5 │ [[]]() { } + · ─ + 6 │ static [{}]() { } + ╰──── + × Super calls are not permitted outside constructors or in nested functions inside constructors. ╭─[typescript/tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES5.ts:4:7] 3 │ class C extends Base { @@ -24197,23 +24338,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts:4:14] + × Expected `;` but found `is` + ╭─[typescript/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts:4:15] 3 │ export class FileSystemObject { 4 │ isFSO: this is FileSystemObject; - · ▲ + · ─┬ + · ╰── `;` expected 5 │ get isFile(): this is File { ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts:4:14] + × Expected `;` but found `is` + ╭─[typescript/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts:4:15] 3 │ export class FileSystemObject { 4 │ isFSO: this is FileSystemObject; - · ▲ + · ─┬ + · ╰── `;` expected 5 │ get isFile(): this is File { ╰──── - help: Try insert a semicolon here × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[typescript/tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration01.ts:1:12] @@ -25717,14 +25858,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 3 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration3.ts:2:9] + × Expected `;` but found `constructor` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration3.ts:2:10] 1 │ class C { 2 │ export constructor() { } - · ▲ + · ─────┬───── + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × TS(1030): public' modifier already seen. ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration6.ts:2:10] @@ -25735,11 +25876,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Remove the duplicate modifier. - × Classes can't have a field named 'constructor' - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration8.ts:3:10] + × Expected `(` but found `;` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration8.ts:3:21] 2 │ // Not a constructor 3 │ public constructor; - · ─────────── + · ┬ + · ╰── `(` expected 4 │ } ╰──── @@ -25912,23 +26054,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErrorRecovery_ClassElement1.ts:5:6] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErrorRecovery_ClassElement1.ts:5:7] 4 │ // this as a source unit element. 5 │ class D { - · ▲ + · ┬ + · ╰── `;` expected 6 │ } ╰──── - help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErrorRecovery_ClassElement2.ts:4:7] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErrorRecovery_ClassElement2.ts:4:8] 3 │ 4 │ enum E { - · ▲ + · ┬ + · ╰── `;` expected 5 │ } ╰──── - help: Try insert a semicolon here × Invalid Character `¬` ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ClassElements/parserErrorRecovery_ClassElement3.ts:2:4] @@ -26036,14 +26178,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Try insert a semicolon here - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts:12:21] + × Expected `;` but found `string` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts:12:22] 11 │ 12 │ public con:C "hello"; - · ▲ + · ───┬─── + · ╰── `;` expected 13 │ // Constructor ╰──── - help: Try insert a semicolon here × Unexpected token ╭─[typescript/tests/cases/conformance/parser/ecmascript5/ErrorRecovery/LeftShifts/parserErrorRecovery_LeftShift1.ts:1:29] @@ -26507,6 +26649,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private · ─ ╰──── + × Expected `;` but found `[` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts:2:18] + 1 │ class C { + 2 │ static static [x: string]: string; + · ┬ + · ╰── `;` expected + 3 │ } + ╰──── + × TS(1071): 'public' modifier cannot appear on an index signature. ╭─[typescript/tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration7.ts:2:4] 1 │ class C { @@ -26523,11 +26674,12 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 3 │ } ╰──── - × Unexpected token + × Expected `;` but found `[` ╭─[typescript/tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration9.ts:2:11] 1 │ class C { 2 │ export [x: string]: string; - · ─ + · ┬ + · ╰── `;` expected 3 │ } ╰──── @@ -26630,14 +26782,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 2 │ } ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts:2:11] + × Expected `;` but found `get` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts:2:12] 1 │ class C { 2 │ export get Foo() { } - · ▲ + · ─┬─ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × A 'get' accessor must not have any formal parameters. ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration12.ts:2:11] @@ -26688,6 +26840,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Remove the duplicate modifier. + × Expected `;` but found `get` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration8.ts:2:19] + 1 │ class C { + 2 │ static static get Foo() { } + · ─┬─ + · ╰── `;` expected + 3 │ } + ╰──── + × TS(1030): public' modifier already seen. ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration1.ts:2:12] 1 │ class C { @@ -26697,14 +26858,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Remove the duplicate modifier. - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration4.ts:2:11] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration2.ts:2:19] + 1 │ class C { + 2 │ static static Foo() { } + · ─┬─ + · ╰── `;` expected + 3 │ } + ╰──── + + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration4.ts:2:12] 1 │ class C { 2 │ export Foo() { } - · ▲ + · ─┬─ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × Identifier `public` has already been declared ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclarationAmbiguities1.ts:2:3] @@ -26771,14 +26941,23 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private ╰──── help: Remove the duplicate modifier. - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration4.ts:2:9] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration2.ts:2:17] + 1 │ class C { + 2 │ static static Foo; + · ─┬─ + · ╰── `;` expected + 3 │ } + ╰──── + + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration4.ts:2:10] 1 │ class C { 2 │ export Foo; - · ▲ + · ─┬─ + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × Unexpected token ╭─[typescript/tests/cases/conformance/parser/ecmascript5/MissingTokens/parserMissingToken1.ts:1:5] @@ -27039,14 +27218,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private · ── ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser585151.ts:2:6] + × Expected `;` but found `Identifier` + ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser585151.ts:2:7] 1 │ class Foo2 { 2 │ var icecream = "chocolate"; - · ▲ + · ────┬─── + · ╰── `;` expected 3 │ } ╰──── - help: Try insert a semicolon here × 'export' modifier cannot be used here. ╭─[typescript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts:1:8] @@ -27892,14 +28071,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 4 │ [e2] = 1 ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none + × Expected `;` but found `:` ╭─[typescript/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName27.ts:4:9] 3 │ [e]: number = 0 4 │ [e2]: number - · ▲ + · ┬ + · ╰── `;` expected 5 │ } ╰──── - help: Try insert a semicolon here × TS(1164): Computed property names are not allowed in enums. ╭─[typescript/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts:3:6] @@ -27909,14 +28088,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 4 │ [e2] = 1 ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts:4:11] + × Expected `;` but found `{` + ╭─[typescript/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName33.ts:4:12] 3 │ [e] = 0 4 │ [e2]() { } - · ▲ + · ┬ + · ╰── `;` expected 5 │ } ╰──── - help: Try insert a semicolon here × TS(1164): Computed property names are not allowed in enums. ╭─[typescript/tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts:3:6] @@ -28097,18 +28276,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private 4 │ } ╰──── - × Multiple constructor implementations are not allowed. - ╭─[typescript/tests/cases/conformance/salsa/constructorNameInAccessor.ts:2:9] - 1 │ class C1 { - 2 │ get constructor() { return } - · ─────┬───── - · ╰── constructor has already been declared here - 3 │ set constructor(value) {} - · ─────┬───── - · ╰── it cannot be redeclared here - 4 │ } - ╰──── - × Constructor can't be a generator ╭─[typescript/tests/cases/conformance/salsa/constructorNameInGenerator.ts:2:6] 1 │ class C2 { diff --git a/tasks/transform_conformance/snapshots/oxc.snap.md b/tasks/transform_conformance/snapshots/oxc.snap.md index 32644350ab6ae..836c10c0abb1b 100644 --- a/tasks/transform_conformance/snapshots/oxc.snap.md +++ b/tasks/transform_conformance/snapshots/oxc.snap.md @@ -637,15 +637,14 @@ rebuilt : ["babelHelpers", "dec"] * typescript/accessor/decoratorOnClassAccessor3/input.ts - x Expected a semicolon or an implicit semicolon after a statement, but found - | none - ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor3/input.ts:6:11] + x Expected `;` but found `@` + ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor3/input.ts:6:12] 5 | class C { 6 | public @dec get accessor() { return 1; } - : ^ + : | + : `-- `;` expected 7 | } `---- - help: Try insert a semicolon here * typescript/accessor/decoratorOnClassAccessor4/input.ts @@ -678,15 +677,14 @@ rebuilt : ["babelHelpers", "dec"] * typescript/accessor/decoratorOnClassAccessor6/input.ts - x Expected a semicolon or an implicit semicolon after a statement, but found - | none - ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor6/input.ts:6:11] + x Expected `;` but found `@` + ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor6/input.ts:6:12] 5 | class C { 6 | public @dec set accessor(value: number) { } - : ^ + : | + : `-- `;` expected 7 | } `---- - help: Try insert a semicolon here * typescript/accessor/decoratorOnClassAccessor7/input.ts @@ -1054,15 +1052,14 @@ rebuilt : ["Function", "babelHelpers", "decorator"] * typescript/method/decoratorOnClassMethod17/input.ts - x Expected a semicolon or an implicit semicolon after a statement, but found - | none - ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/input.ts:7:17] + x Expected `;` but found `@` + ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/input.ts:7:18] 6 | class Foo { 7 | private prop @decorator - : ^ + : | + : `-- `;` expected 8 | foo() { `---- - help: Try insert a semicolon here * typescript/method/decoratorOnClassMethod18/input.ts @@ -1095,15 +1092,14 @@ rebuilt : ["babelHelpers", "dec"] * typescript/method/decoratorOnClassMethod3/input.ts - x Expected a semicolon or an implicit semicolon after a statement, but found - | none - ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod3/input.ts:6:11] + x Expected `;` but found `@` + ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod3/input.ts:6:12] 5 | class C { 6 | public @dec method() {} - : ^ + : | + : `-- `;` expected 7 | } `---- - help: Try insert a semicolon here * typescript/method/decoratorOnClassMethod4/input.ts @@ -1349,15 +1345,14 @@ rebuilt : ["babelHelpers", "dec"] * typescript/property/decoratorOnClassProperty3/input.ts - x Expected a semicolon or an implicit semicolon after a statement, but found - | none - ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty3/input.ts:6:11] + x Expected `;` but found `@` + ,-[tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty3/input.ts:6:12] 5 | class C { 6 | public @dec prop; - : ^ + : | + : `-- `;` expected 7 | } `---- - help: Try insert a semicolon here * typescript/property/decoratorOnClassProperty6/input.ts