diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index f0f864b9699d6..1c35a4b62c97b 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2607,8 +2607,9 @@ pub struct ExportNamedDeclaration<'a> { #[estree(add_fields(exportKind = TsValue))] pub struct ExportDefaultDeclaration<'a> { pub span: Span, + /// Span of the `default` keyword #[estree(skip)] - pub exported: ModuleExportName<'a>, // the `default` Keyword + pub default_span: Span, pub declaration: ExportDefaultDeclarationKind<'a>, } diff --git a/crates/oxc_ast/src/generated/assert_layouts.rs b/crates/oxc_ast/src/generated/assert_layouts.rs index cd72040702331..83c5cee5972af 100644 --- a/crates/oxc_ast/src/generated/assert_layouts.rs +++ b/crates/oxc_ast/src/generated/assert_layouts.rs @@ -818,11 +818,11 @@ const _: () = { assert!(offset_of!(ExportNamedDeclaration, with_clause) == 96); // Padding: 0 bytes - assert!(size_of::() == 80); + assert!(size_of::() == 32); assert!(align_of::() == 8); assert!(offset_of!(ExportDefaultDeclaration, span) == 0); - assert!(offset_of!(ExportDefaultDeclaration, exported) == 8); - assert!(offset_of!(ExportDefaultDeclaration, declaration) == 64); + assert!(offset_of!(ExportDefaultDeclaration, default_span) == 8); + assert!(offset_of!(ExportDefaultDeclaration, declaration) == 16); // Padding: 7 bytes assert!(size_of::() == 128); @@ -2413,11 +2413,11 @@ const _: () = { assert!(offset_of!(ExportNamedDeclaration, with_clause) == 60); // Padding: 0 bytes - assert!(size_of::() == 48); + assert!(size_of::() == 24); assert!(align_of::() == 4); assert!(offset_of!(ExportDefaultDeclaration, span) == 0); - assert!(offset_of!(ExportDefaultDeclaration, exported) == 8); - assert!(offset_of!(ExportDefaultDeclaration, declaration) == 40); + assert!(offset_of!(ExportDefaultDeclaration, default_span) == 8); + assert!(offset_of!(ExportDefaultDeclaration, declaration) == 16); // Padding: 3 bytes assert!(size_of::() == 76); diff --git a/crates/oxc_ast/src/generated/ast_builder.rs b/crates/oxc_ast/src/generated/ast_builder.rs index 22e216d09cba3..1f5eaeec2339b 100644 --- a/crates/oxc_ast/src/generated/ast_builder.rs +++ b/crates/oxc_ast/src/generated/ast_builder.rs @@ -7181,18 +7181,18 @@ impl<'a> AstBuilder<'a> { /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `exported` + /// * `default_span`: Span of the `default` keyword /// * `declaration` #[inline] pub fn module_declaration_export_default_declaration( self, span: Span, - exported: ModuleExportName<'a>, + default_span: Span, declaration: ExportDefaultDeclarationKind<'a>, ) -> ModuleDeclaration<'a> { ModuleDeclaration::ExportDefaultDeclaration(self.alloc_export_default_declaration( span, - exported, + default_span, declaration, )) } @@ -7839,16 +7839,16 @@ impl<'a> AstBuilder<'a> { /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `exported` + /// * `default_span`: Span of the `default` keyword /// * `declaration` #[inline] pub fn export_default_declaration( self, span: Span, - exported: ModuleExportName<'a>, + default_span: Span, declaration: ExportDefaultDeclarationKind<'a>, ) -> ExportDefaultDeclaration<'a> { - ExportDefaultDeclaration { span, exported, declaration } + ExportDefaultDeclaration { span, default_span, declaration } } /// Build an [`ExportDefaultDeclaration`], and store it in the memory arena. @@ -7858,16 +7858,19 @@ impl<'a> AstBuilder<'a> { /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `exported` + /// * `default_span`: Span of the `default` keyword /// * `declaration` #[inline] pub fn alloc_export_default_declaration( self, span: Span, - exported: ModuleExportName<'a>, + default_span: Span, declaration: ExportDefaultDeclarationKind<'a>, ) -> Box<'a, ExportDefaultDeclaration<'a>> { - Box::new_in(self.export_default_declaration(span, exported, declaration), self.allocator) + Box::new_in( + self.export_default_declaration(span, default_span, declaration), + self.allocator, + ) } /// Build an [`ExportAllDeclaration`]. diff --git a/crates/oxc_ast/src/generated/derive_clone_in.rs b/crates/oxc_ast/src/generated/derive_clone_in.rs index 2f23d0bb5c0ed..f75177306bf37 100644 --- a/crates/oxc_ast/src/generated/derive_clone_in.rs +++ b/crates/oxc_ast/src/generated/derive_clone_in.rs @@ -4362,7 +4362,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for ExportDefaultDeclaration<'_> { fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { ExportDefaultDeclaration { span: CloneIn::clone_in(&self.span, allocator), - exported: CloneIn::clone_in(&self.exported, allocator), + default_span: CloneIn::clone_in(&self.default_span, allocator), declaration: CloneIn::clone_in(&self.declaration, allocator), } } @@ -4370,7 +4370,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for ExportDefaultDeclaration<'_> { fn clone_in_with_semantic_ids(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { ExportDefaultDeclaration { span: CloneIn::clone_in_with_semantic_ids(&self.span, allocator), - exported: CloneIn::clone_in_with_semantic_ids(&self.exported, allocator), + default_span: CloneIn::clone_in_with_semantic_ids(&self.default_span, allocator), declaration: CloneIn::clone_in_with_semantic_ids(&self.declaration, allocator), } } diff --git a/crates/oxc_ast/src/generated/derive_content_eq.rs b/crates/oxc_ast/src/generated/derive_content_eq.rs index ab519651c5a1c..5006ed33f2854 100644 --- a/crates/oxc_ast/src/generated/derive_content_eq.rs +++ b/crates/oxc_ast/src/generated/derive_content_eq.rs @@ -1360,8 +1360,7 @@ impl ContentEq for ExportNamedDeclaration<'_> { impl ContentEq for ExportDefaultDeclaration<'_> { fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.exported, &other.exported) - && ContentEq::content_eq(&self.declaration, &other.declaration) + ContentEq::content_eq(&self.declaration, &other.declaration) } } diff --git a/crates/oxc_ast/src/generated/derive_dummy.rs b/crates/oxc_ast/src/generated/derive_dummy.rs index 6307e54836e3b..92f062a1d62d1 100644 --- a/crates/oxc_ast/src/generated/derive_dummy.rs +++ b/crates/oxc_ast/src/generated/derive_dummy.rs @@ -1495,7 +1495,7 @@ impl<'a> Dummy<'a> for ExportDefaultDeclaration<'a> { fn dummy(allocator: &'a Allocator) -> Self { Self { span: Dummy::dummy(allocator), - exported: Dummy::dummy(allocator), + default_span: Dummy::dummy(allocator), declaration: Dummy::dummy(allocator), } } diff --git a/crates/oxc_ast_visit/src/generated/visit.rs b/crates/oxc_ast_visit/src/generated/visit.rs index 14752c30e59f0..6265afd691bca 100644 --- a/crates/oxc_ast_visit/src/generated/visit.rs +++ b/crates/oxc_ast_visit/src/generated/visit.rs @@ -2801,7 +2801,7 @@ pub mod walk { let kind = AstKind::ExportDefaultDeclaration(visitor.alloc(it)); visitor.enter_node(kind); visitor.visit_span(&it.span); - visitor.visit_module_export_name(&it.exported); + visitor.visit_span(&it.default_span); visitor.visit_export_default_declaration_kind(&it.declaration); visitor.leave_node(kind); } diff --git a/crates/oxc_ast_visit/src/generated/visit_mut.rs b/crates/oxc_ast_visit/src/generated/visit_mut.rs index 83e02bab5c5e4..bb5f928aef05e 100644 --- a/crates/oxc_ast_visit/src/generated/visit_mut.rs +++ b/crates/oxc_ast_visit/src/generated/visit_mut.rs @@ -2911,7 +2911,7 @@ pub mod walk_mut { let kind = AstType::ExportDefaultDeclaration; visitor.enter_node(kind); visitor.visit_span(&mut it.span); - visitor.visit_module_export_name(&mut it.exported); + visitor.visit_span(&mut it.default_span); visitor.visit_export_default_declaration_kind(&mut it.declaration); visitor.leave_node(kind); } diff --git a/crates/oxc_formatter/src/generated/ast_nodes.rs b/crates/oxc_formatter/src/generated/ast_nodes.rs index d1b9e753b18c1..77270a79ac1ae 100644 --- a/crates/oxc_formatter/src/generated/ast_nodes.rs +++ b/crates/oxc_formatter/src/generated/ast_nodes.rs @@ -8948,14 +8948,8 @@ impl<'a> GetSpan for AstNode<'a, ExportNamedDeclaration<'a>> { impl<'a> AstNode<'a, ExportDefaultDeclaration<'a>> { #[inline] - pub fn exported(&self) -> &AstNode<'a, ModuleExportName<'a>> { - let following_node = Some(SiblingNode::from(&self.inner.declaration)); - self.allocator.alloc(AstNode { - inner: &self.inner.exported, - allocator: self.allocator, - parent: self.allocator.alloc(AstNodes::ExportDefaultDeclaration(transmute_self(self))), - following_node, - }) + pub fn default_span(&self) -> Span { + self.inner.default_span } #[inline] diff --git a/crates/oxc_isolated_declarations/src/module.rs b/crates/oxc_isolated_declarations/src/module.rs index dacb577ca28da..078ed2ca29954 100644 --- a/crates/oxc_isolated_declarations/src/module.rs +++ b/crates/oxc_isolated_declarations/src/module.rs @@ -57,8 +57,6 @@ impl<'a> IsolatedDeclarations<'a> { }; declaration.map(|(var_decl, declaration)| { - let exported = - ModuleExportName::IdentifierName(self.ast.identifier_name(SPAN, "default")); // When `var_decl` is Some, the comments are moved to the variable declaration, otherwise // keep the comments on the export default declaration to avoid losing them. // ```ts @@ -82,7 +80,7 @@ impl<'a> IsolatedDeclarations<'a> { let span = if var_decl.is_some() { SPAN } else { decl.span }; let declaration = - self.ast.module_declaration_export_default_declaration(span, exported, declaration); + self.ast.module_declaration_export_default_declaration(span, SPAN, declaration); (var_decl, Statement::from(declaration)) }) } diff --git a/crates/oxc_parser/src/js/module.rs b/crates/oxc_parser/src/js/module.rs index a78209e1cd636..c63cf26fb3bb2 100644 --- a/crates/oxc_parser/src/js/module.rs +++ b/crates/oxc_parser/src/js/module.rs @@ -543,11 +543,11 @@ impl<'a> ParserImpl<'a> { span: u32, decorators: Vec<'a, Decorator<'a>>, ) -> Box<'a, ExportDefaultDeclaration<'a>> { - let exported = self.parse_keyword_identifier(Kind::Default); + let default_span = self.cur_token().span(); + self.bump_remap(Kind::Default); let declaration = self.parse_export_default_declaration_kind(decorators); - let exported = ModuleExportName::IdentifierName(exported); let span = self.end_span(span); - self.ast.alloc_export_default_declaration(span, exported, declaration) + self.ast.alloc_export_default_declaration(span, default_span, declaration) } fn parse_export_default_declaration_kind( diff --git a/crates/oxc_parser/src/module_record.rs b/crates/oxc_parser/src/module_record.rs index 11513ca7cbfca..1815d230b1218 100644 --- a/crates/oxc_parser/src/module_record.rs +++ b/crates/oxc_parser/src/module_record.rs @@ -284,8 +284,6 @@ impl<'a> ModuleRecordBuilder<'a> { } fn visit_export_default_declaration(&mut self, decl: &ExportDefaultDeclaration<'a>) { - let exported_name = &decl.exported; - let local_name = match &decl.declaration { ExportDefaultDeclarationKind::Identifier(ident) => { ExportLocalName::Default(NameSpan::new(ident.name, ident.span)) @@ -310,7 +308,7 @@ impl<'a> ModuleRecordBuilder<'a> { span: decl.declaration.span(), module_request: None, import_name: ExportImportName::default(), - export_name: ExportExportName::Default(exported_name.span()), + export_name: ExportExportName::Default(decl.default_span), local_name, is_type: decl.is_typescript_syntax(), }; diff --git a/crates/oxc_semantic/tests/fixtures/oxc/ts/exports/default/type-alias.snap b/crates/oxc_semantic/tests/fixtures/oxc/ts/exports/default/type-alias.snap index 9b3d19ad438bc..a154f88ad55f4 100644 --- a/crates/oxc_semantic/tests/fixtures/oxc/ts/exports/default/type-alias.snap +++ b/crates/oxc_semantic/tests/fixtures/oxc/ts/exports/default/type-alias.snap @@ -27,7 +27,7 @@ input_file: crates/oxc_semantic/tests/fixtures/oxc/ts/exports/default/type-alias "flags": "ReferenceFlags(Type)", "id": 0, "name": "A", - "node_id": 6 + "node_id": 5 } ] } diff --git a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default-type.snap b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default-type.snap index 3ff25b2dc866b..99b477058d148 100644 --- a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default-type.snap +++ b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default-type.snap @@ -27,7 +27,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default- "flags": "ReferenceFlags(Read)", "id": 0, "name": "T", - "node_id": 11 + "node_id": 10 } ] } diff --git a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default2.snap b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default2.snap index 4770d04e5659a..688f062b8da30 100644 --- a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default2.snap +++ b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default2.snap @@ -19,7 +19,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/default2 "flags": "ReferenceFlags(Read)", "id": 0, "name": "a", - "node_id": 7 + "node_id": 6 } ] } diff --git a/crates/oxc_transformer/src/decorator/legacy/mod.rs b/crates/oxc_transformer/src/decorator/legacy/mod.rs index 8d6ba0b1c8f3a..a7239de9b2a2e 100644 --- a/crates/oxc_transformer/src/decorator/legacy/mod.rs +++ b/crates/oxc_transformer/src/decorator/legacy/mod.rs @@ -1032,7 +1032,7 @@ impl<'a> LegacyDecorator<'a, '_> { ) -> Statement<'a> { let export_default_class_reference = ctx.ast.module_declaration_export_default_declaration( SPAN, - ctx.ast.module_export_name_identifier_name(SPAN, "default"), + SPAN, ExportDefaultDeclarationKind::Identifier( ctx.ast.alloc(class_binding.create_read_reference(ctx)), ), diff --git a/crates/oxc_traverse/src/generated/ancestor.rs b/crates/oxc_traverse/src/generated/ancestor.rs index 0a0fe0af5a59d..5dd21314d3f13 100644 --- a/crates/oxc_traverse/src/generated/ancestor.rs +++ b/crates/oxc_traverse/src/generated/ancestor.rs @@ -183,139 +183,138 @@ pub(crate) enum AncestorType { ExportNamedDeclarationSpecifiers = 158, ExportNamedDeclarationSource = 159, ExportNamedDeclarationWithClause = 160, - ExportDefaultDeclarationExported = 161, - ExportDefaultDeclarationDeclaration = 162, - ExportAllDeclarationExported = 163, - ExportAllDeclarationSource = 164, - ExportAllDeclarationWithClause = 165, - ExportSpecifierLocal = 166, - ExportSpecifierExported = 167, - V8IntrinsicExpressionName = 168, - V8IntrinsicExpressionArguments = 169, - JSXElementOpeningElement = 170, - JSXElementChildren = 171, - JSXElementClosingElement = 172, - JSXOpeningElementName = 173, - JSXOpeningElementTypeArguments = 174, - JSXOpeningElementAttributes = 175, - JSXClosingElementName = 176, - JSXFragmentOpeningFragment = 177, - JSXFragmentChildren = 178, - JSXFragmentClosingFragment = 179, - JSXNamespacedNameNamespace = 180, - JSXNamespacedNameName = 181, - JSXMemberExpressionObject = 182, - JSXMemberExpressionProperty = 183, - JSXExpressionContainerExpression = 184, - JSXAttributeName = 185, - JSXAttributeValue = 186, - JSXSpreadAttributeArgument = 187, - JSXSpreadChildExpression = 188, - TSThisParameterTypeAnnotation = 189, - TSEnumDeclarationId = 190, - TSEnumDeclarationBody = 191, - TSEnumBodyMembers = 192, - TSEnumMemberId = 193, - TSEnumMemberInitializer = 194, - TSTypeAnnotationTypeAnnotation = 195, - TSLiteralTypeLiteral = 196, - TSConditionalTypeCheckType = 197, - TSConditionalTypeExtendsType = 198, - TSConditionalTypeTrueType = 199, - TSConditionalTypeFalseType = 200, - TSUnionTypeTypes = 201, - TSIntersectionTypeTypes = 202, - TSParenthesizedTypeTypeAnnotation = 203, - TSTypeOperatorTypeAnnotation = 204, - TSArrayTypeElementType = 205, - TSIndexedAccessTypeObjectType = 206, - TSIndexedAccessTypeIndexType = 207, - TSTupleTypeElementTypes = 208, - TSNamedTupleMemberLabel = 209, - TSNamedTupleMemberElementType = 210, - TSOptionalTypeTypeAnnotation = 211, - TSRestTypeTypeAnnotation = 212, - TSTypeReferenceTypeName = 213, - TSTypeReferenceTypeArguments = 214, - TSQualifiedNameLeft = 215, - TSQualifiedNameRight = 216, - TSTypeParameterInstantiationParams = 217, - TSTypeParameterName = 218, - TSTypeParameterConstraint = 219, - TSTypeParameterDefault = 220, - TSTypeParameterDeclarationParams = 221, - TSTypeAliasDeclarationId = 222, - TSTypeAliasDeclarationTypeParameters = 223, - TSTypeAliasDeclarationTypeAnnotation = 224, - TSClassImplementsExpression = 225, - TSClassImplementsTypeArguments = 226, - TSInterfaceDeclarationId = 227, - TSInterfaceDeclarationTypeParameters = 228, - TSInterfaceDeclarationExtends = 229, - TSInterfaceDeclarationBody = 230, - TSInterfaceBodyBody = 231, - TSPropertySignatureKey = 232, - TSPropertySignatureTypeAnnotation = 233, - TSIndexSignatureParameters = 234, - TSIndexSignatureTypeAnnotation = 235, - TSCallSignatureDeclarationTypeParameters = 236, - TSCallSignatureDeclarationThisParam = 237, - TSCallSignatureDeclarationParams = 238, - TSCallSignatureDeclarationReturnType = 239, - TSMethodSignatureKey = 240, - TSMethodSignatureTypeParameters = 241, - TSMethodSignatureThisParam = 242, - TSMethodSignatureParams = 243, - TSMethodSignatureReturnType = 244, - TSConstructSignatureDeclarationTypeParameters = 245, - TSConstructSignatureDeclarationParams = 246, - TSConstructSignatureDeclarationReturnType = 247, - TSIndexSignatureNameTypeAnnotation = 248, - TSInterfaceHeritageExpression = 249, - TSInterfaceHeritageTypeArguments = 250, - TSTypePredicateParameterName = 251, - TSTypePredicateTypeAnnotation = 252, - TSModuleDeclarationId = 253, - TSModuleDeclarationBody = 254, - TSModuleBlockDirectives = 255, - TSModuleBlockBody = 256, - TSTypeLiteralMembers = 257, - TSInferTypeTypeParameter = 258, - TSTypeQueryExprName = 259, - TSTypeQueryTypeArguments = 260, - TSImportTypeArgument = 261, - TSImportTypeOptions = 262, - TSImportTypeQualifier = 263, - TSImportTypeTypeArguments = 264, - TSFunctionTypeTypeParameters = 265, - TSFunctionTypeThisParam = 266, - TSFunctionTypeParams = 267, - TSFunctionTypeReturnType = 268, - TSConstructorTypeTypeParameters = 269, - TSConstructorTypeParams = 270, - TSConstructorTypeReturnType = 271, - TSMappedTypeTypeParameter = 272, - TSMappedTypeNameType = 273, - TSMappedTypeTypeAnnotation = 274, - TSTemplateLiteralTypeQuasis = 275, - TSTemplateLiteralTypeTypes = 276, - TSAsExpressionExpression = 277, - TSAsExpressionTypeAnnotation = 278, - TSSatisfiesExpressionExpression = 279, - TSSatisfiesExpressionTypeAnnotation = 280, - TSTypeAssertionTypeAnnotation = 281, - TSTypeAssertionExpression = 282, - TSImportEqualsDeclarationId = 283, - TSImportEqualsDeclarationModuleReference = 284, - TSExternalModuleReferenceExpression = 285, - TSNonNullExpressionExpression = 286, - DecoratorExpression = 287, - TSExportAssignmentExpression = 288, - TSNamespaceExportDeclarationId = 289, - TSInstantiationExpressionExpression = 290, - TSInstantiationExpressionTypeArguments = 291, - JSDocNullableTypeTypeAnnotation = 292, - JSDocNonNullableTypeTypeAnnotation = 293, + ExportDefaultDeclarationDeclaration = 161, + ExportAllDeclarationExported = 162, + ExportAllDeclarationSource = 163, + ExportAllDeclarationWithClause = 164, + ExportSpecifierLocal = 165, + ExportSpecifierExported = 166, + V8IntrinsicExpressionName = 167, + V8IntrinsicExpressionArguments = 168, + JSXElementOpeningElement = 169, + JSXElementChildren = 170, + JSXElementClosingElement = 171, + JSXOpeningElementName = 172, + JSXOpeningElementTypeArguments = 173, + JSXOpeningElementAttributes = 174, + JSXClosingElementName = 175, + JSXFragmentOpeningFragment = 176, + JSXFragmentChildren = 177, + JSXFragmentClosingFragment = 178, + JSXNamespacedNameNamespace = 179, + JSXNamespacedNameName = 180, + JSXMemberExpressionObject = 181, + JSXMemberExpressionProperty = 182, + JSXExpressionContainerExpression = 183, + JSXAttributeName = 184, + JSXAttributeValue = 185, + JSXSpreadAttributeArgument = 186, + JSXSpreadChildExpression = 187, + TSThisParameterTypeAnnotation = 188, + TSEnumDeclarationId = 189, + TSEnumDeclarationBody = 190, + TSEnumBodyMembers = 191, + TSEnumMemberId = 192, + TSEnumMemberInitializer = 193, + TSTypeAnnotationTypeAnnotation = 194, + TSLiteralTypeLiteral = 195, + TSConditionalTypeCheckType = 196, + TSConditionalTypeExtendsType = 197, + TSConditionalTypeTrueType = 198, + TSConditionalTypeFalseType = 199, + TSUnionTypeTypes = 200, + TSIntersectionTypeTypes = 201, + TSParenthesizedTypeTypeAnnotation = 202, + TSTypeOperatorTypeAnnotation = 203, + TSArrayTypeElementType = 204, + TSIndexedAccessTypeObjectType = 205, + TSIndexedAccessTypeIndexType = 206, + TSTupleTypeElementTypes = 207, + TSNamedTupleMemberLabel = 208, + TSNamedTupleMemberElementType = 209, + TSOptionalTypeTypeAnnotation = 210, + TSRestTypeTypeAnnotation = 211, + TSTypeReferenceTypeName = 212, + TSTypeReferenceTypeArguments = 213, + TSQualifiedNameLeft = 214, + TSQualifiedNameRight = 215, + TSTypeParameterInstantiationParams = 216, + TSTypeParameterName = 217, + TSTypeParameterConstraint = 218, + TSTypeParameterDefault = 219, + TSTypeParameterDeclarationParams = 220, + TSTypeAliasDeclarationId = 221, + TSTypeAliasDeclarationTypeParameters = 222, + TSTypeAliasDeclarationTypeAnnotation = 223, + TSClassImplementsExpression = 224, + TSClassImplementsTypeArguments = 225, + TSInterfaceDeclarationId = 226, + TSInterfaceDeclarationTypeParameters = 227, + TSInterfaceDeclarationExtends = 228, + TSInterfaceDeclarationBody = 229, + TSInterfaceBodyBody = 230, + TSPropertySignatureKey = 231, + TSPropertySignatureTypeAnnotation = 232, + TSIndexSignatureParameters = 233, + TSIndexSignatureTypeAnnotation = 234, + TSCallSignatureDeclarationTypeParameters = 235, + TSCallSignatureDeclarationThisParam = 236, + TSCallSignatureDeclarationParams = 237, + TSCallSignatureDeclarationReturnType = 238, + TSMethodSignatureKey = 239, + TSMethodSignatureTypeParameters = 240, + TSMethodSignatureThisParam = 241, + TSMethodSignatureParams = 242, + TSMethodSignatureReturnType = 243, + TSConstructSignatureDeclarationTypeParameters = 244, + TSConstructSignatureDeclarationParams = 245, + TSConstructSignatureDeclarationReturnType = 246, + TSIndexSignatureNameTypeAnnotation = 247, + TSInterfaceHeritageExpression = 248, + TSInterfaceHeritageTypeArguments = 249, + TSTypePredicateParameterName = 250, + TSTypePredicateTypeAnnotation = 251, + TSModuleDeclarationId = 252, + TSModuleDeclarationBody = 253, + TSModuleBlockDirectives = 254, + TSModuleBlockBody = 255, + TSTypeLiteralMembers = 256, + TSInferTypeTypeParameter = 257, + TSTypeQueryExprName = 258, + TSTypeQueryTypeArguments = 259, + TSImportTypeArgument = 260, + TSImportTypeOptions = 261, + TSImportTypeQualifier = 262, + TSImportTypeTypeArguments = 263, + TSFunctionTypeTypeParameters = 264, + TSFunctionTypeThisParam = 265, + TSFunctionTypeParams = 266, + TSFunctionTypeReturnType = 267, + TSConstructorTypeTypeParameters = 268, + TSConstructorTypeParams = 269, + TSConstructorTypeReturnType = 270, + TSMappedTypeTypeParameter = 271, + TSMappedTypeNameType = 272, + TSMappedTypeTypeAnnotation = 273, + TSTemplateLiteralTypeQuasis = 274, + TSTemplateLiteralTypeTypes = 275, + TSAsExpressionExpression = 276, + TSAsExpressionTypeAnnotation = 277, + TSSatisfiesExpressionExpression = 278, + TSSatisfiesExpressionTypeAnnotation = 279, + TSTypeAssertionTypeAnnotation = 280, + TSTypeAssertionExpression = 281, + TSImportEqualsDeclarationId = 282, + TSImportEqualsDeclarationModuleReference = 283, + TSExternalModuleReferenceExpression = 284, + TSNonNullExpressionExpression = 285, + DecoratorExpression = 286, + TSExportAssignmentExpression = 287, + TSNamespaceExportDeclarationId = 288, + TSInstantiationExpressionExpression = 289, + TSInstantiationExpressionTypeArguments = 290, + JSDocNullableTypeTypeAnnotation = 291, + JSDocNonNullableTypeTypeAnnotation = 292, } /// Ancestor type used in AST traversal. @@ -622,8 +621,6 @@ pub enum Ancestor<'a, 't> { AncestorType::ExportNamedDeclarationSource as u16, ExportNamedDeclarationWithClause(ExportNamedDeclarationWithoutWithClause<'a, 't>) = AncestorType::ExportNamedDeclarationWithClause as u16, - ExportDefaultDeclarationExported(ExportDefaultDeclarationWithoutExported<'a, 't>) = - AncestorType::ExportDefaultDeclarationExported as u16, ExportDefaultDeclarationDeclaration(ExportDefaultDeclarationWithoutDeclaration<'a, 't>) = AncestorType::ExportDefaultDeclarationDeclaration as u16, ExportAllDeclarationExported(ExportAllDeclarationWithoutExported<'a, 't>) = @@ -1397,11 +1394,7 @@ impl<'a, 't> Ancestor<'a, 't> { #[inline] pub fn is_export_default_declaration(self) -> bool { - matches!( - self, - Self::ExportDefaultDeclarationExported(_) - | Self::ExportDefaultDeclarationDeclaration(_) - ) + matches!(self, Self::ExportDefaultDeclarationDeclaration(_)) } #[inline] @@ -2042,7 +2035,6 @@ impl<'a, 't> Ancestor<'a, 't> { matches!( self, Self::ImportSpecifierImported(_) - | Self::ExportDefaultDeclarationExported(_) | Self::ExportAllDeclarationExported(_) | Self::ExportSpecifierLocal(_) | Self::ExportSpecifierExported(_) @@ -2357,7 +2349,6 @@ impl<'a, 't> GetAddress for Ancestor<'a, 't> { Self::ExportNamedDeclarationSpecifiers(a) => a.address(), Self::ExportNamedDeclarationSource(a) => a.address(), Self::ExportNamedDeclarationWithClause(a) => a.address(), - Self::ExportDefaultDeclarationExported(a) => a.address(), Self::ExportDefaultDeclarationDeclaration(a) => a.address(), Self::ExportAllDeclarationExported(a) => a.address(), Self::ExportAllDeclarationSource(a) => a.address(), @@ -10103,42 +10094,11 @@ impl<'a, 't> GetAddress for ExportNamedDeclarationWithoutWithClause<'a, 't> { pub(crate) const OFFSET_EXPORT_DEFAULT_DECLARATION_SPAN: usize = offset_of!(ExportDefaultDeclaration, span); -pub(crate) const OFFSET_EXPORT_DEFAULT_DECLARATION_EXPORTED: usize = - offset_of!(ExportDefaultDeclaration, exported); +pub(crate) const OFFSET_EXPORT_DEFAULT_DECLARATION_DEFAULT_SPAN: usize = + offset_of!(ExportDefaultDeclaration, default_span); pub(crate) const OFFSET_EXPORT_DEFAULT_DECLARATION_DECLARATION: usize = offset_of!(ExportDefaultDeclaration, declaration); -#[repr(transparent)] -#[derive(Clone, Copy, Debug)] -pub struct ExportDefaultDeclarationWithoutExported<'a, 't>( - pub(crate) *const ExportDefaultDeclaration<'a>, - pub(crate) PhantomData<&'t ()>, -); - -impl<'a, 't> ExportDefaultDeclarationWithoutExported<'a, 't> { - #[inline] - pub fn span(self) -> &'t Span { - unsafe { - &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_SPAN) as *const Span) - } - } - - #[inline] - pub fn declaration(self) -> &'t ExportDefaultDeclarationKind<'a> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_DECLARATION) - as *const ExportDefaultDeclarationKind<'a>) - } - } -} - -impl<'a, 't> GetAddress for ExportDefaultDeclarationWithoutExported<'a, 't> { - #[inline] - fn address(&self) -> Address { - Address::from_ptr(self.0) - } -} - #[repr(transparent)] #[derive(Clone, Copy, Debug)] pub struct ExportDefaultDeclarationWithoutDeclaration<'a, 't>( @@ -10155,10 +10115,10 @@ impl<'a, 't> ExportDefaultDeclarationWithoutDeclaration<'a, 't> { } #[inline] - pub fn exported(self) -> &'t ModuleExportName<'a> { + pub fn default_span(self) -> &'t Span { unsafe { - &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_EXPORTED) - as *const ModuleExportName<'a>) + &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_DEFAULT_SPAN) + as *const Span) } } } diff --git a/crates/oxc_traverse/src/generated/walk.rs b/crates/oxc_traverse/src/generated/walk.rs index 4b2530bf5b7c1..0bdc34f4dd708 100644 --- a/crates/oxc_traverse/src/generated/walk.rs +++ b/crates/oxc_traverse/src/generated/walk.rs @@ -2987,16 +2987,9 @@ unsafe fn walk_export_default_declaration<'a, State, Tr: Traverse<'a, State>>( ctx: &mut TraverseCtx<'a, State>, ) { traverser.enter_export_default_declaration(&mut *node, ctx); - let pop_token = ctx.push_stack(Ancestor::ExportDefaultDeclarationExported( - ancestor::ExportDefaultDeclarationWithoutExported(node, PhantomData), + let pop_token = ctx.push_stack(Ancestor::ExportDefaultDeclarationDeclaration( + ancestor::ExportDefaultDeclarationWithoutDeclaration(node, PhantomData), )); - walk_module_export_name( - traverser, - (node as *mut u8).add(ancestor::OFFSET_EXPORT_DEFAULT_DECLARATION_EXPORTED) - as *mut ModuleExportName, - ctx, - ); - ctx.retag_stack(AncestorType::ExportDefaultDeclarationDeclaration); walk_export_default_declaration_kind( traverser, (node as *mut u8).add(ancestor::OFFSET_EXPORT_DEFAULT_DECLARATION_DECLARATION) diff --git a/napi/parser/generated/deserialize/js.js b/napi/parser/generated/deserialize/js.js index 83eb661ea7f5f..84370511f2c62 100644 --- a/napi/parser/generated/deserialize/js.js +++ b/napi/parser/generated/deserialize/js.js @@ -987,7 +987,7 @@ function deserializeExportNamedDeclaration(pos) { function deserializeExportDefaultDeclaration(pos) { return { type: 'ExportDefaultDeclaration', - declaration: deserializeExportDefaultDeclarationKind(pos + 64), + declaration: deserializeExportDefaultDeclarationKind(pos + 16), start: deserializeU32(pos), end: deserializeU32(pos + 4), }; diff --git a/napi/parser/generated/deserialize/ts.js b/napi/parser/generated/deserialize/ts.js index 0d01bad4f571c..b2181bbe027d1 100644 --- a/napi/parser/generated/deserialize/ts.js +++ b/napi/parser/generated/deserialize/ts.js @@ -1116,7 +1116,7 @@ function deserializeExportNamedDeclaration(pos) { function deserializeExportDefaultDeclaration(pos) { return { type: 'ExportDefaultDeclaration', - declaration: deserializeExportDefaultDeclarationKind(pos + 64), + declaration: deserializeExportDefaultDeclarationKind(pos + 16), exportKind: 'value', start: deserializeU32(pos), end: deserializeU32(pos + 4), diff --git a/napi/parser/generated/lazy/constructors.js b/napi/parser/generated/lazy/constructors.js index 57e77298a1bae..9073a44382086 100644 --- a/napi/parser/generated/lazy/constructors.js +++ b/napi/parser/generated/lazy/constructors.js @@ -5965,7 +5965,7 @@ class ExportDefaultDeclaration { get declaration() { const internal = this.#internal; - return constructExportDefaultDeclarationKind(internal.pos + 64, internal.ast); + return constructExportDefaultDeclarationKind(internal.pos + 16, internal.ast); } toJSON() { diff --git a/napi/parser/generated/lazy/walk.js b/napi/parser/generated/lazy/walk.js index 40d404c45ac8b..60b2733e68a06 100644 --- a/napi/parser/generated/lazy/walk.js +++ b/napi/parser/generated/lazy/walk.js @@ -2437,7 +2437,7 @@ function walkExportDefaultDeclaration(pos, ast, visitors) { if (enter !== null) enter(node); } - walkExportDefaultDeclarationKind(pos + 64, ast, visitors); + walkExportDefaultDeclarationKind(pos + 16, ast, visitors); if (exit !== null) exit(node); }