diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index beaf6b3e321ee..a590952569f03 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1592,12 +1592,12 @@ pub struct Class<'a> { pub decorators: Vec<'a, Decorator<'a>>, #[scope(enter_before)] pub id: Option>, + pub type_parameters: Option>>, #[visit_as(ClassHeritage)] pub super_class: Option>, - pub body: Box<'a, ClassBody<'a>>, - pub type_parameters: Option>>, pub super_type_parameters: Option>>, pub implements: Option>>, + pub body: Box<'a, ClassBody<'a>>, pub r#abstract: bool, pub declare: bool, pub scope_id: Cell>, diff --git a/crates/oxc_ast/src/generated/ast_builder.rs b/crates/oxc_ast/src/generated/ast_builder.rs index a254161a27360..5034aef8b361a 100644 --- a/crates/oxc_ast/src/generated/ast_builder.rs +++ b/crates/oxc_ast/src/generated/ast_builder.rs @@ -485,29 +485,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Expression<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { Expression::ClassExpression(self.alloc(self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ))) @@ -2728,29 +2728,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Declaration<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { Declaration::ClassDeclaration(self.alloc(self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ))) @@ -3942,29 +3942,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Class<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { Class { r#type, span, decorators, id, - super_class, - body: body.into_in(self.allocator), type_parameters: type_parameters.into_in(self.allocator), + super_class, super_type_parameters: super_type_parameters.into_in(self.allocator), implements, + body: body.into_in(self.allocator), r#abstract, declare, scope_id: Default::default(), @@ -3978,29 +3978,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> Box<'a, Class<'a>> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ) @@ -4943,29 +4943,29 @@ impl<'a> AstBuilder<'a> { span: Span, decorators: Vec<'a, Decorator<'a>>, id: Option>, + type_parameters: T1, super_class: Option>, - body: T1, - type_parameters: T2, - super_type_parameters: T3, + super_type_parameters: T2, implements: Option>>, + body: T3, r#abstract: bool, declare: bool, ) -> ExportDefaultDeclarationKind<'a> where - T1: IntoIn<'a, Box<'a, ClassBody<'a>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, ClassBody<'a>>>, { ExportDefaultDeclarationKind::ClassDeclaration(self.alloc(self.class( r#type, span, decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, r#abstract, declare, ))) diff --git a/crates/oxc_ast/src/generated/visit.rs b/crates/oxc_ast/src/generated/visit.rs index 41e0805c0b18f..ddfe5c856dc93 100644 --- a/crates/oxc_ast/src/generated/visit.rs +++ b/crates/oxc_ast/src/generated/visit.rs @@ -803,6 +803,16 @@ pub trait Visit<'a>: Sized { walk_class_heritage(self, it); } + #[inline] + fn visit_ts_class_implementses(&mut self, it: &Vec<'a, TSClassImplements<'a>>) { + walk_ts_class_implementses(self, it); + } + + #[inline] + fn visit_ts_class_implements(&mut self, it: &TSClassImplements<'a>) { + walk_ts_class_implements(self, it); + } + #[inline] fn visit_class_body(&mut self, it: &ClassBody<'a>) { walk_class_body(self, it); @@ -843,16 +853,6 @@ pub trait Visit<'a>: Sized { walk_accessor_property(self, it); } - #[inline] - fn visit_ts_class_implementses(&mut self, it: &Vec<'a, TSClassImplements<'a>>) { - walk_ts_class_implementses(self, it); - } - - #[inline] - fn visit_ts_class_implements(&mut self, it: &TSClassImplements<'a>) { - walk_ts_class_implements(self, it); - } - #[inline] fn visit_conditional_expression(&mut self, it: &ConditionalExpression<'a>) { walk_conditional_expression(self, it); @@ -2929,19 +2929,19 @@ pub mod walk { if let Some(id) = &it.id { visitor.visit_binding_identifier(id); } - if let Some(super_class) = &it.super_class { - visitor.visit_class_heritage(super_class); - } - visitor.visit_class_body(&it.body); if let Some(type_parameters) = &it.type_parameters { visitor.visit_ts_type_parameter_declaration(type_parameters); } + if let Some(super_class) = &it.super_class { + visitor.visit_class_heritage(super_class); + } if let Some(super_type_parameters) = &it.super_type_parameters { visitor.visit_ts_type_parameter_instantiation(super_type_parameters); } if let Some(implements) = &it.implements { visitor.visit_ts_class_implementses(implements); } + visitor.visit_class_body(&it.body); visitor.leave_scope(); visitor.leave_node(kind); } @@ -2953,6 +2953,27 @@ pub mod walk { visitor.leave_node(kind); } + #[inline] + pub fn walk_ts_class_implementses<'a, V: Visit<'a>>( + visitor: &mut V, + it: &Vec<'a, TSClassImplements<'a>>, + ) { + for el in it.iter() { + visitor.visit_ts_class_implements(el); + } + } + + #[inline] + pub fn walk_ts_class_implements<'a, V: Visit<'a>>(visitor: &mut V, it: &TSClassImplements<'a>) { + let kind = AstKind::TSClassImplements(visitor.alloc(it)); + visitor.enter_node(kind); + visitor.visit_ts_type_name(&it.expression); + if let Some(type_parameters) = &it.type_parameters { + visitor.visit_ts_type_parameter_instantiation(type_parameters); + } + visitor.leave_node(kind); + } + #[inline] pub fn walk_class_body<'a, V: Visit<'a>>(visitor: &mut V, it: &ClassBody<'a>) { let kind = AstKind::ClassBody(visitor.alloc(it)); @@ -3072,27 +3093,6 @@ pub mod walk { } } - #[inline] - pub fn walk_ts_class_implementses<'a, V: Visit<'a>>( - visitor: &mut V, - it: &Vec<'a, TSClassImplements<'a>>, - ) { - for el in it.iter() { - visitor.visit_ts_class_implements(el); - } - } - - #[inline] - pub fn walk_ts_class_implements<'a, V: Visit<'a>>(visitor: &mut V, it: &TSClassImplements<'a>) { - let kind = AstKind::TSClassImplements(visitor.alloc(it)); - visitor.enter_node(kind); - visitor.visit_ts_type_name(&it.expression); - if let Some(type_parameters) = &it.type_parameters { - visitor.visit_ts_type_parameter_instantiation(type_parameters); - } - visitor.leave_node(kind); - } - #[inline] pub fn walk_conditional_expression<'a, V: Visit<'a>>( visitor: &mut V, diff --git a/crates/oxc_ast/src/generated/visit_mut.rs b/crates/oxc_ast/src/generated/visit_mut.rs index ca3de8cc3a195..fecc459acbc39 100644 --- a/crates/oxc_ast/src/generated/visit_mut.rs +++ b/crates/oxc_ast/src/generated/visit_mut.rs @@ -795,6 +795,16 @@ pub trait VisitMut<'a>: Sized { walk_class_heritage(self, it); } + #[inline] + fn visit_ts_class_implementses(&mut self, it: &mut Vec<'a, TSClassImplements<'a>>) { + walk_ts_class_implementses(self, it); + } + + #[inline] + fn visit_ts_class_implements(&mut self, it: &mut TSClassImplements<'a>) { + walk_ts_class_implements(self, it); + } + #[inline] fn visit_class_body(&mut self, it: &mut ClassBody<'a>) { walk_class_body(self, it); @@ -835,16 +845,6 @@ pub trait VisitMut<'a>: Sized { walk_accessor_property(self, it); } - #[inline] - fn visit_ts_class_implementses(&mut self, it: &mut Vec<'a, TSClassImplements<'a>>) { - walk_ts_class_implementses(self, it); - } - - #[inline] - fn visit_ts_class_implements(&mut self, it: &mut TSClassImplements<'a>) { - walk_ts_class_implements(self, it); - } - #[inline] fn visit_conditional_expression(&mut self, it: &mut ConditionalExpression<'a>) { walk_conditional_expression(self, it); @@ -3053,19 +3053,19 @@ pub mod walk_mut { if let Some(id) = &mut it.id { visitor.visit_binding_identifier(id); } - if let Some(super_class) = &mut it.super_class { - visitor.visit_class_heritage(super_class); - } - visitor.visit_class_body(&mut it.body); if let Some(type_parameters) = &mut it.type_parameters { visitor.visit_ts_type_parameter_declaration(type_parameters); } + if let Some(super_class) = &mut it.super_class { + visitor.visit_class_heritage(super_class); + } if let Some(super_type_parameters) = &mut it.super_type_parameters { visitor.visit_ts_type_parameter_instantiation(super_type_parameters); } if let Some(implements) = &mut it.implements { visitor.visit_ts_class_implementses(implements); } + visitor.visit_class_body(&mut it.body); visitor.leave_scope(); visitor.leave_node(kind); } @@ -3077,6 +3077,30 @@ pub mod walk_mut { visitor.leave_node(kind); } + #[inline] + pub fn walk_ts_class_implementses<'a, V: VisitMut<'a>>( + visitor: &mut V, + it: &mut Vec<'a, TSClassImplements<'a>>, + ) { + for el in it.iter_mut() { + visitor.visit_ts_class_implements(el); + } + } + + #[inline] + pub fn walk_ts_class_implements<'a, V: VisitMut<'a>>( + visitor: &mut V, + it: &mut TSClassImplements<'a>, + ) { + let kind = AstType::TSClassImplements; + visitor.enter_node(kind); + visitor.visit_ts_type_name(&mut it.expression); + if let Some(type_parameters) = &mut it.type_parameters { + visitor.visit_ts_type_parameter_instantiation(type_parameters); + } + visitor.leave_node(kind); + } + #[inline] pub fn walk_class_body<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut ClassBody<'a>) { let kind = AstType::ClassBody; @@ -3205,30 +3229,6 @@ pub mod walk_mut { } } - #[inline] - pub fn walk_ts_class_implementses<'a, V: VisitMut<'a>>( - visitor: &mut V, - it: &mut Vec<'a, TSClassImplements<'a>>, - ) { - for el in it.iter_mut() { - visitor.visit_ts_class_implements(el); - } - } - - #[inline] - pub fn walk_ts_class_implements<'a, V: VisitMut<'a>>( - visitor: &mut V, - it: &mut TSClassImplements<'a>, - ) { - let kind = AstType::TSClassImplements; - visitor.enter_node(kind); - visitor.visit_ts_type_name(&mut it.expression); - if let Some(type_parameters) = &mut it.type_parameters { - visitor.visit_ts_type_parameter_instantiation(type_parameters); - } - visitor.leave_node(kind); - } - #[inline] pub fn walk_conditional_expression<'a, V: VisitMut<'a>>( visitor: &mut V, diff --git a/crates/oxc_isolated_declarations/src/class.rs b/crates/oxc_isolated_declarations/src/class.rs index 7c93e6f7300fd..20ef7f00915d8 100644 --- a/crates/oxc_isolated_declarations/src/class.rs +++ b/crates/oxc_isolated_declarations/src/class.rs @@ -490,11 +490,11 @@ impl<'a> IsolatedDeclarations<'a> { decl.span, self.ast.vec(), self.ast.copy(&decl.id), - self.ast.copy(&decl.super_class), - body, self.ast.copy(&decl.type_parameters), + self.ast.copy(&decl.super_class), self.ast.copy(&decl.super_type_parameters), self.ast.copy(&decl.implements), + body, decl.r#abstract, declare.unwrap_or_else(|| self.is_declare()), )) diff --git a/crates/oxc_linter/src/snapshots/ban_types.snap b/crates/oxc_linter/src/snapshots/ban_types.snap index 1ccb251dec195..a8e4839260bac 100644 --- a/crates/oxc_linter/src/snapshots/ban_types.snap +++ b/crates/oxc_linter/src/snapshots/ban_types.snap @@ -175,6 +175,14 @@ source: crates/oxc_linter/src/tester.rs 3 │ constructor(foo: String | Object | Function) {} ╰──── + ⚠ typescript-eslint(ban-types): 'The `Object` type actually means "any non-nullish value" + ╭─[ban_types.tsx:2:68] + 1 │ + 2 │ class Test extends Foo implements Bar { + · ────── + 3 │ constructor(foo: String | Object | Function) {} + ╰──── + ⚠ typescript-eslint(ban-types): Do not use "String" as a type. Use "string" instead ╭─[ban_types.tsx:3:28] 2 │ class Test extends Foo implements Bar { diff --git a/crates/oxc_parser/src/js/class.rs b/crates/oxc_parser/src/js/class.rs index 77ab8288b3369..f606af61cf96a 100644 --- a/crates/oxc_parser/src/js/class.rs +++ b/crates/oxc_parser/src/js/class.rs @@ -99,11 +99,11 @@ impl<'a> ParserImpl<'a> { self.end_span(start_span), decorators, id, - super_class, - body, type_parameters, + super_class, super_type_parameters, implements, + body, modifiers.contains_abstract(), modifiers.contains_declare(), )) diff --git a/crates/oxc_semantic/src/binder.rs b/crates/oxc_semantic/src/binder.rs index ce14e8a08a682..a5b67627ee1c3 100644 --- a/crates/oxc_semantic/src/binder.rs +++ b/crates/oxc_semantic/src/binder.rs @@ -78,13 +78,17 @@ impl<'a> Binder for VariableDeclarator<'a> { impl<'a> Binder for Class<'a> { fn bind(&self, builder: &mut SemanticBuilder) { - let Some(ident) = &self.id else { return }; if !self.declare { + let Some(ident) = &self.id else { return }; let symbol_id = builder.declare_symbol( ident.span, &ident.name, SymbolFlags::Class, - SymbolFlags::ClassExcludes, + if self.is_declaration() { + SymbolFlags::ClassExcludes + } else { + SymbolFlags::empty() + }, ); ident.symbol_id.set(Some(symbol_id)); } diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index ca19d1258812b..fb97b57573f05 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -414,6 +414,16 @@ impl<'a> SemanticBuilder<'a> { self.symbols.union_flag(symbol_id, SymbolFlags::Export); } } + + fn bind_class_expression(&mut self) { + if let AstKind::Class(class) = self.nodes.kind(self.current_node_id) { + if class.is_expression() { + // We must to bind class expression when enter BindingIdentifier, + // because we should add binding to current scope + class.bind(self); + } + } + } } impl<'a> Visit<'a> for SemanticBuilder<'a> { @@ -444,6 +454,10 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> { if self.unresolved_references.len() <= self.current_scope_depth { self.unresolved_references.push(UnresolvedReferences::default()); } + + if !flags.is_top() { + self.bind_class_expression(); + } } fn leave_scope(&mut self) { @@ -1453,46 +1467,6 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> { self.leave_scope(); } - fn visit_class(&mut self, class: &Class<'a>) { - // Class level decorators are transpiled as functions outside of the class taking the class - // itself as argument. They should be visited before class is entered. E.g., they inherit - // strict mode from the enclosing scope rather than from class. - for decorator in &class.decorators { - self.visit_decorator(decorator); - } - let kind = AstKind::Class(self.alloc(class)); - - // FIXME(don): Should we enter a scope when visiting class declarations? - let is_class_expr = class.r#type == ClassType::ClassExpression; - if is_class_expr { - // Class expressions create a temporary scope with the class name as its only variable - // E.g., `let c = class A { foo() { console.log(A) } }` - self.enter_scope(ScopeFlags::empty(), &class.scope_id); - } - - self.enter_node(kind); - - if let Some(id) = &class.id { - self.visit_binding_identifier(id); - } - if let Some(parameters) = &class.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); - } - - if let Some(super_class) = &class.super_class { - self.visit_class_heritage(super_class); - } - if let Some(super_parameters) = &class.super_type_parameters { - self.visit_ts_type_parameter_instantiation(super_parameters); - } - self.visit_class_body(&class.body); - - self.leave_node(kind); - if is_class_expr { - self.leave_scope(); - } - } - fn visit_arrow_function_expression(&mut self, expr: &ArrowFunctionExpression<'a>) { let kind = AstKind::ArrowFunctionExpression(self.alloc(expr)); self.enter_scope(ScopeFlags::Function | ScopeFlags::Arrow, &expr.scope_id); @@ -1606,7 +1580,9 @@ impl<'a> SemanticBuilder<'a> { } AstKind::Class(class) => { self.current_node_flags |= NodeFlags::Class; - class.bind(self); + if class.is_declaration() { + class.bind(self); + } self.current_symbol_flags -= SymbolFlags::Export; self.make_all_namespaces_valuelike(); } diff --git a/crates/oxc_semantic/src/checker/javascript.rs b/crates/oxc_semantic/src/checker/javascript.rs index 396c7cde49d33..6e2024274fe57 100644 --- a/crates/oxc_semantic/src/checker/javascript.rs +++ b/crates/oxc_semantic/src/checker/javascript.rs @@ -137,8 +137,15 @@ pub fn check_identifier<'a>(name: &str, span: Span, node: &AstNode<'a>, ctx: &Se if ctx.source_type.is_module() { return ctx.error(reserved_keyword(name, span)); } + // It is a Syntax Error if ClassStaticBlockStatementList Contains await is true. - if ctx.scope.get_flags(node.scope_id()).is_class_static_block() { + if (matches!(ctx.nodes.parent_kind(node.id()), Some(AstKind::Class(_))) + && ctx + .scope + .get_parent_id(node.scope_id()) + .is_some_and(|id| ctx.scope.get_flags(id).is_class_static_block())) + || ctx.current_scope_flags().is_class_static_block() + { return ctx.error(class_static_block_await(span)); } } diff --git a/crates/oxc_traverse/src/ancestor.rs b/crates/oxc_traverse/src/ancestor.rs index 02f78af89c23e..e79b91ef385d1 100644 --- a/crates/oxc_traverse/src/ancestor.rs +++ b/crates/oxc_traverse/src/ancestor.rs @@ -158,11 +158,11 @@ pub(crate) enum AncestorType { YieldExpressionArgument = 126, ClassDecorators = 127, ClassId = 128, - ClassSuperClass = 129, - ClassBody = 130, - ClassTypeParameters = 131, - ClassSuperTypeParameters = 132, - ClassImplements = 133, + ClassTypeParameters = 129, + ClassSuperClass = 130, + ClassSuperTypeParameters = 131, + ClassImplements = 132, + ClassBody = 133, ClassBodyBody = 134, MethodDefinitionDecorators = 135, MethodDefinitionKey = 136, @@ -557,12 +557,12 @@ pub enum Ancestor<'a> { AncestorType::YieldExpressionArgument as u16, ClassDecorators(ClassWithoutDecorators<'a>) = AncestorType::ClassDecorators as u16, ClassId(ClassWithoutId<'a>) = AncestorType::ClassId as u16, - ClassSuperClass(ClassWithoutSuperClass<'a>) = AncestorType::ClassSuperClass as u16, - ClassBody(ClassWithoutBody<'a>) = AncestorType::ClassBody as u16, ClassTypeParameters(ClassWithoutTypeParameters<'a>) = AncestorType::ClassTypeParameters as u16, + ClassSuperClass(ClassWithoutSuperClass<'a>) = AncestorType::ClassSuperClass as u16, ClassSuperTypeParameters(ClassWithoutSuperTypeParameters<'a>) = AncestorType::ClassSuperTypeParameters as u16, ClassImplements(ClassWithoutImplements<'a>) = AncestorType::ClassImplements as u16, + ClassBody(ClassWithoutBody<'a>) = AncestorType::ClassBody as u16, ClassBodyBody(ClassBodyWithoutBody<'a>) = AncestorType::ClassBodyBody as u16, MethodDefinitionDecorators(MethodDefinitionWithoutDecorators<'a>) = AncestorType::MethodDefinitionDecorators as u16, @@ -1284,11 +1284,11 @@ impl<'a> Ancestor<'a> { self, Self::ClassDecorators(_) | Self::ClassId(_) - | Self::ClassSuperClass(_) - | Self::ClassBody(_) | Self::ClassTypeParameters(_) + | Self::ClassSuperClass(_) | Self::ClassSuperTypeParameters(_) | Self::ClassImplements(_) + | Self::ClassBody(_) ) } @@ -6135,12 +6135,12 @@ pub(crate) const OFFSET_CLASS_TYPE: usize = offset_of!(Class, r#type); pub(crate) const OFFSET_CLASS_SPAN: usize = offset_of!(Class, span); pub(crate) const OFFSET_CLASS_DECORATORS: usize = offset_of!(Class, decorators); pub(crate) const OFFSET_CLASS_ID: usize = offset_of!(Class, id); -pub(crate) const OFFSET_CLASS_SUPER_CLASS: usize = offset_of!(Class, super_class); -pub(crate) const OFFSET_CLASS_BODY: usize = offset_of!(Class, body); pub(crate) const OFFSET_CLASS_TYPE_PARAMETERS: usize = offset_of!(Class, type_parameters); +pub(crate) const OFFSET_CLASS_SUPER_CLASS: usize = offset_of!(Class, super_class); pub(crate) const OFFSET_CLASS_SUPER_TYPE_PARAMETERS: usize = offset_of!(Class, super_type_parameters); pub(crate) const OFFSET_CLASS_IMPLEMENTS: usize = offset_of!(Class, implements); +pub(crate) const OFFSET_CLASS_BODY: usize = offset_of!(Class, body); pub(crate) const OFFSET_CLASS_ABSTRACT: usize = offset_of!(Class, r#abstract); pub(crate) const OFFSET_CLASS_DECLARE: usize = offset_of!(Class, declare); pub(crate) const OFFSET_CLASS_SCOPE_ID: usize = offset_of!(Class, scope_id); @@ -6168,22 +6168,17 @@ impl<'a> ClassWithoutDecorators<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6203,6 +6198,11 @@ impl<'a> ClassWithoutDecorators<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6244,22 +6244,17 @@ impl<'a> ClassWithoutId<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6279,6 +6274,11 @@ impl<'a> ClassWithoutId<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6299,9 +6299,9 @@ impl<'a> ClassWithoutId<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutSuperClass<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutTypeParameters<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutSuperClass<'a> { +impl<'a> ClassWithoutTypeParameters<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6327,15 +6327,9 @@ impl<'a> ClassWithoutSuperClass<'a> { } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6355,6 +6349,11 @@ impl<'a> ClassWithoutSuperClass<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6375,9 +6374,9 @@ impl<'a> ClassWithoutSuperClass<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutBody<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutSuperClass<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutBody<'a> { +impl<'a> ClassWithoutSuperClass<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6402,13 +6401,6 @@ impl<'a> ClassWithoutBody<'a> { } } - #[inline] - pub fn super_class(&self) -> &Option> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) - } - } - #[inline] pub fn type_parameters(&self) -> &Option>> { unsafe { @@ -6433,6 +6425,11 @@ impl<'a> ClassWithoutBody<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6453,9 +6450,9 @@ impl<'a> ClassWithoutBody<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutTypeParameters<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutSuperTypeParameters<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutTypeParameters<'a> { +impl<'a> ClassWithoutSuperTypeParameters<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6481,22 +6478,17 @@ impl<'a> ClassWithoutTypeParameters<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn super_type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6508,6 +6500,11 @@ impl<'a> ClassWithoutTypeParameters<'a> { } } + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } @@ -6528,9 +6525,9 @@ impl<'a> ClassWithoutTypeParameters<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutSuperTypeParameters<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutImplements<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutSuperTypeParameters<'a> { +impl<'a> ClassWithoutImplements<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6556,31 +6553,31 @@ impl<'a> ClassWithoutSuperTypeParameters<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } } #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn implements(&self) -> &Option>> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) - as *const Option>>) - } + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } } #[inline] @@ -6603,9 +6600,9 @@ impl<'a> ClassWithoutSuperTypeParameters<'a> { #[repr(transparent)] #[derive(Debug)] -pub struct ClassWithoutImplements<'a>(pub(crate) *const Class<'a>); +pub struct ClassWithoutBody<'a>(pub(crate) *const Class<'a>); -impl<'a> ClassWithoutImplements<'a> { +impl<'a> ClassWithoutBody<'a> { #[inline] pub fn r#type(&self) -> &ClassType { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } @@ -6631,22 +6628,17 @@ impl<'a> ClassWithoutImplements<'a> { } #[inline] - pub fn super_class(&self) -> &Option> { + pub fn type_parameters(&self) -> &Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) } } #[inline] - pub fn body(&self) -> &Box<'a, ClassBody<'a>> { - unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } - } - - #[inline] - pub fn type_parameters(&self) -> &Option>> { + pub fn super_class(&self) -> &Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) } } @@ -6658,6 +6650,14 @@ impl<'a> ClassWithoutImplements<'a> { } } + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + #[inline] pub fn r#abstract(&self) -> &bool { unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) } diff --git a/crates/oxc_traverse/src/walk.rs b/crates/oxc_traverse/src/walk.rs index 9361a1aa78dda..59eb3a3e2f297 100644 --- a/crates/oxc_traverse/src/walk.rs +++ b/crates/oxc_traverse/src/walk.rs @@ -2473,25 +2473,18 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>( ctx.retag_stack(AncestorType::ClassId); walk_binding_identifier(traverser, field as *mut _, ctx); } - if let Some(field) = - &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_CLASS) as *mut Option) - { - ctx.retag_stack(AncestorType::ClassSuperClass); - walk_expression(traverser, field as *mut _, ctx); - } - ctx.retag_stack(AncestorType::ClassBody); - walk_class_body( - traverser, - (&mut **((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY) as *mut Box)) - as *mut _, - ctx, - ); if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_TYPE_PARAMETERS) as *mut Option>) { ctx.retag_stack(AncestorType::ClassTypeParameters); walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); } + if let Some(field) = + &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_CLASS) as *mut Option) + { + ctx.retag_stack(AncestorType::ClassSuperClass); + walk_expression(traverser, field as *mut _, ctx); + } if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_TYPE_PARAMETERS) as *mut Option>) { @@ -2506,6 +2499,13 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>( walk_ts_class_implements(traverser, item as *mut _, ctx); } } + ctx.retag_stack(AncestorType::ClassBody); + walk_class_body( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY) as *mut Box)) + as *mut _, + ctx, + ); ctx.pop_stack(); if let Some(previous_scope_id) = previous_scope_id { ctx.set_current_scope_id(previous_scope_id); diff --git a/tasks/coverage/parser_test262.snap b/tasks/coverage/parser_test262.snap index 214a54144fb7c..ad84a4c5b0c87 100644 --- a/tasks/coverage/parser_test262.snap +++ b/tasks/coverage/parser_test262.snap @@ -2,12 +2,60 @@ commit: a1587416 parser_test262 Summary: AST Parsed : 45859/45859 (100.00%) -Positive Passed: 45859/45859 (100.00%) +Positive Passed: 45853/45859 (99.99%) Negative Passed: 3925/3929 (99.90%) Expect Syntax Error: "language/import/import-assertions/json-invalid.js" Expect Syntax Error: "language/import/import-assertions/json-named-bindings.js" Expect Syntax Error: "language/import/import-attributes/json-invalid.js" Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" +Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/expressions/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js:44:10] + 43 │ + 44 │ var C = @yield() class {}; + · ───── + ╰──── +Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/expressions/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js:33:10] + 32 │ + 33 │ var C = @yield class {}; + · ───── + ╰──── +Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/expressions/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js:51:11] + 50 │ + 51 │ var C = @(yield) class {}; + · ───── + ╰──── +Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js:45:2] + 44 │ + 45 │ @yield() class C {} + · ───── + ╰──── +Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js:34:2] + 33 │ + 34 │ @yield class C {} + · ───── + ╰──── +Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js" + + × The keyword 'yield' is reserved + ╭─[language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js:52:3] + 51 │ + 52 │ @(yield) class C {} + · ───── + ╰──── × '0'-prefixed octal literals and octal escape sequences are deprecated ╭─[annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict.js:18:4] @@ -12629,6 +12677,14 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js" × Cannot use `await` as an identifier in an async context ╭─[language/expressions/class/static-init-await-binding.js:21:12] 20 │ static { + 21 │ (class await {}); + · ───── + 22 │ } + ╰──── + + × Cannot use await in class static initialization block + ╭─[language/expressions/class/static-init-await-binding.js:21:12] + 20 │ static { 21 │ (class await {}); · ───── 22 │ } diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index b0acdb5f6a398..eeaa6aeee9807 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -2,8 +2,8 @@ commit: d8086f14 parser_typescript Summary: AST Parsed : 5279/5283 (99.92%) -Positive Passed: 5256/5283 (99.49%) -Negative Passed: 1103/4875 (22.63%) +Positive Passed: 5258/5283 (99.53%) +Negative Passed: 1100/4875 (22.56%) Expect Syntax Error: "compiler/ClassDeclaration10.ts" Expect Syntax Error: "compiler/ClassDeclaration11.ts" Expect Syntax Error: "compiler/ClassDeclaration13.ts" @@ -469,6 +469,7 @@ Expect Syntax Error: "compiler/decoratorInJsFile.ts" Expect Syntax Error: "compiler/decoratorInJsFile1.ts" Expect Syntax Error: "compiler/decoratorMetadataGenericTypeVariable.ts" Expect Syntax Error: "compiler/decoratorMetadataGenericTypeVariableDefault.ts" +Expect Syntax Error: "compiler/decoratorMetadataGenericTypeVariableInScope.ts" Expect Syntax Error: "compiler/decoratorMetadataNoLibIsolatedModulesTypes.ts" Expect Syntax Error: "compiler/decoratorsOnComputedProperties.ts" Expect Syntax Error: "compiler/deduplicateImportsInSystem.ts" @@ -888,6 +889,7 @@ Expect Syntax Error: "compiler/importedModuleAddToGlobal.ts" Expect Syntax Error: "compiler/inDoesNotOperateOnPrimitiveTypes.ts" Expect Syntax Error: "compiler/inKeywordAndUnknown.ts" Expect Syntax Error: "compiler/inOperator.ts" +Expect Syntax Error: "compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts" Expect Syntax Error: "compiler/incompatibleExports1.ts" Expect Syntax Error: "compiler/incompatibleExports2.ts" Expect Syntax Error: "compiler/incompatibleGenericTypes.ts" @@ -2625,6 +2627,7 @@ Expect Syntax Error: "conformance/expressions/contextualTyping/parenthesizedCont Expect Syntax Error: "conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts" Expect Syntax Error: "conformance/expressions/contextualTyping/superCallParameterContextualTyping2.ts" Expect Syntax Error: "conformance/expressions/functionCalls/callOverload.ts" +Expect Syntax Error: "conformance/expressions/functionCalls/callWithMissingVoid.ts" Expect Syntax Error: "conformance/expressions/functionCalls/callWithSpread2.ts" Expect Syntax Error: "conformance/expressions/functionCalls/callWithSpread3.ts" Expect Syntax Error: "conformance/expressions/functionCalls/callWithSpread4.ts" @@ -3799,20 +3802,6 @@ Expect to Parse: "compiler/bom-utf16be.ts" 1 │ ￾瘀愀爀 砀㴀㄀ 㬀ഀ਀ · ─ ╰──── -Expect to Parse: "compiler/decoratorReferences.ts" - - × Identifier `T` has already been declared - ╭─[compiler/decoratorReferences.ts:2:6] - 1 │ declare function y(...args: any[]): any; - 2 │ type T = number; - · ┬ - · ╰── `T` has already been declared here - 3 │ @y(1 as T, () => C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class - 4 │ class C { - · ┬ - · ╰── It can not be redeclared here - 5 │ @y(null as T) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class - ╰──── Expect to Parse: "compiler/deferredConditionalTypes.ts" × Identifier `A` has already been declared @@ -4090,21 +4079,6 @@ Expect to Parse: "compiler/unusedTypeParametersNotCheckedByNoUnusedLocals.ts" · ╰── It can not be redeclared here 6 │ ╰──── - - × Identifier `T` has already been declared - ╭─[compiler/unusedTypeParametersNotCheckedByNoUnusedLocals.ts:3:6] - 2 │ - 3 │ type T = { }; - · ┬ - · ╰── `T` has already been declared here - 4 │ - 5 │ interface I { }; - 6 │ - 7 │ class C { - · ┬ - · ╰── It can not be redeclared here - 8 │ public m() { } - ╰──── Expect to Parse: "compiler/withStatementInternalComments.ts" × 'with' statements are not allowed @@ -4204,17 +4178,6 @@ Expect to Parse: "conformance/esDecorators/esDecorators-decoratorExpression.1.ts 14 │ ╰──── help: Try insert a semicolon here -Expect to Parse: "conformance/expressions/newOperator/newOperatorConformance.ts" - - × Identifier `T` has already been declared - ╭─[conformance/expressions/newOperator/newOperatorConformance.ts:8:7] - 7 │ - 8 │ class T { - · ┬ ┬ - · │ ╰── It can not be redeclared here - · ╰── `T` has already been declared here - 9 │ constructor(n?: T) { } - ╰──── Expect to Parse: "conformance/externalModules/topLevelAwait.2.ts" × Cannot use `await` as an identifier in an async context @@ -6347,19 +6310,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje ╰──── help: Remove the duplicate modifier. - × Identifier `TypeVariable` has already been declared - ╭─[compiler/decoratorMetadataGenericTypeVariableInScope.ts:2:7] - 1 │ // Unused, but could collide with the named type argument below. - 2 │ class TypeVariable {} - · ──────┬───── - · ╰── `TypeVariable` has already been declared here - 3 │ - 4 │ export class C { - · ──────┬───── - · ╰── It can not be redeclared here - 5 │ @Decorate - ╰──── - × Cannot assign to this expression ╭─[compiler/decrementAndIncrementOperators.ts:4:1] 3 │ // errors @@ -7419,18 +7369,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje 2 │ ╰──── - × Identifier `T` has already been declared - ╭─[compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts:1:11] - 1 │ interface T { } - · ┬ - · ╰── `T` has already been declared here - 2 │ declare const a: T; - 3 │ class Foo { - · ┬ - · ╰── It can not be redeclared here - 4 │ x: T; - ╰──── - × Unexpected token ╭─[compiler/incompleteDottedExpressionAtEOF.ts:2:18] 1 │ // used to leak __missing into error message @@ -10298,21 +10236,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje 16 │ } ╰──── - × Identifier `public` has already been declared - ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:1:11] - 1 │ interface public { } - · ───┬── - · ╰── `public` has already been declared here - 2 │ - ╰──── - ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:21:9] - 20 │ - 21 │ class D{ } - · ───┬── - · ╰── It can not be redeclared here - 22 │ - ╰──── - × The keyword 'public' is reserved ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:21:9] 20 │ @@ -10329,6 +10252,30 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje 22 │ ╰──── + × The keyword 'public' is reserved + ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:23:20] + 22 │ + 23 │ class E implements public { } + · ────── + 24 │ + ╰──── + + × The keyword 'public' is reserved + ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:25:20] + 24 │ + 25 │ class F implements public.private.B { } + · ────── + 26 │ class F1 implements public.private.implements { } + ╰──── + + × The keyword 'public' is reserved + ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:26:21] + 25 │ class F implements public.private.B { } + 26 │ class F1 implements public.private.implements { } + · ────── + 27 │ class G extends package { } + ╰──── + × The keyword 'package' is reserved ╭─[compiler/strictModeReservedWordInClassDeclaration.ts:27:17] 26 │ class F1 implements public.private.implements { } @@ -11235,21 +11182,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje 6 │ ╰──── - × Identifier `T` has already been declared - ╭─[compiler/unusedTypeParametersCheckedByNoUnusedParameters.ts:3:6] - 2 │ - 3 │ type T = { }; - · ┬ - · ╰── `T` has already been declared here - 4 │ - 5 │ interface I { }; - 6 │ - 7 │ class C { - · ┬ - · ╰── It can not be redeclared here - 8 │ public m() { } - ╰──── - × Expected a semicolon or an implicit semicolon after a statement, but found none ╭─[compiler/validRegexp.ts:1:23] 1 │ var x = / [a - z /]$ / i; @@ -16494,22 +16426,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje 10 │ (BOOLEAN, ); ╰──── - × Identifier `X` has already been declared - ╭─[conformance/expressions/functionCalls/callWithMissingVoid.ts:2:7] - 1 │ // From #4260 - 2 │ class X { - · ┬ - · ╰── `X` has already been declared here - 3 │ f(t: T) { - ╰──── - ╭─[conformance/expressions/functionCalls/callWithMissingVoid.ts:27:17] - 26 │ - 27 │ class MyPromise { - · ┬ - · ╰── It can not be redeclared here - 28 │ constructor(executor: (resolve: (value: X) => void) => void) { - ╰──── - × 'with' statements are not allowed ╭─[conformance/expressions/functions/arrowFunctionContexts.ts:2:1] 1 │ // Arrow function used in with statement