diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 8af22de575cf6..940f8de2902a6 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -1278,12 +1278,12 @@ pub enum TSTypeQueryExprName<'a> { #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] pub struct TSImportType<'a> { pub span: Span, + pub argument: TSType<'a>, + pub options: Option>>, + pub qualifier: Option>, + pub type_arguments: Option>>, /// `true` for `typeof import("foo")` pub is_type_of: bool, - pub parameter: TSType<'a>, - pub qualifier: Option>, - pub attributes: Option>>, - pub type_parameters: Option>>, } #[ast(visit)] diff --git a/crates/oxc_ast/src/generated/assert_layouts.rs b/crates/oxc_ast/src/generated/assert_layouts.rs index b1528fde33f71..ec7710ae31283 100644 --- a/crates/oxc_ast/src/generated/assert_layouts.rs +++ b/crates/oxc_ast/src/generated/assert_layouts.rs @@ -1256,11 +1256,11 @@ const _: () = { assert!(size_of::() == 64); assert!(align_of::() == 8); assert!(offset_of!(TSImportType, span) == 0); - assert!(offset_of!(TSImportType, is_type_of) == 8); - assert!(offset_of!(TSImportType, parameter) == 16); + assert!(offset_of!(TSImportType, argument) == 8); + assert!(offset_of!(TSImportType, options) == 24); assert!(offset_of!(TSImportType, qualifier) == 32); - assert!(offset_of!(TSImportType, attributes) == 48); - assert!(offset_of!(TSImportType, type_parameters) == 56); + assert!(offset_of!(TSImportType, type_arguments) == 48); + assert!(offset_of!(TSImportType, is_type_of) == 56); assert!(size_of::() == 64); assert!(align_of::() == 8); @@ -2660,11 +2660,11 @@ const _: () = { assert!(size_of::() == 36); assert!(align_of::() == 4); assert!(offset_of!(TSImportType, span) == 0); - assert!(offset_of!(TSImportType, is_type_of) == 8); - assert!(offset_of!(TSImportType, parameter) == 12); + assert!(offset_of!(TSImportType, argument) == 8); + assert!(offset_of!(TSImportType, options) == 16); assert!(offset_of!(TSImportType, qualifier) == 20); - assert!(offset_of!(TSImportType, attributes) == 28); - assert!(offset_of!(TSImportType, type_parameters) == 32); + assert!(offset_of!(TSImportType, type_arguments) == 28); + assert!(offset_of!(TSImportType, is_type_of) == 32); assert!(size_of::() == 40); assert!(align_of::() == 4); diff --git a/crates/oxc_ast/src/generated/ast_builder.rs b/crates/oxc_ast/src/generated/ast_builder.rs index 612d56c899261..e7f4a18d679d6 100644 --- a/crates/oxc_ast/src/generated/ast_builder.rs +++ b/crates/oxc_ast/src/generated/ast_builder.rs @@ -10306,20 +10306,20 @@ impl<'a> AstBuilder<'a> { /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` + /// * `argument` + /// * `options` /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `type_arguments` + /// * `is_type_of`: `true` for `typeof import("foo")` #[inline] pub fn ts_type_import_type( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, + argument: TSType<'a>, + options: T1, qualifier: Option>, - attributes: T1, - type_parameters: T2, + type_arguments: T2, + is_type_of: bool, ) -> TSType<'a> where T1: IntoIn<'a, Option>>>, @@ -10327,11 +10327,11 @@ impl<'a> AstBuilder<'a> { { TSType::TSImportType(self.alloc_ts_import_type( span, - is_type_of, - parameter, + argument, + options, qualifier, - attributes, - type_parameters, + type_arguments, + is_type_of, )) } @@ -13422,20 +13422,20 @@ impl<'a> AstBuilder<'a> { /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` + /// * `argument` + /// * `options` /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `type_arguments` + /// * `is_type_of`: `true` for `typeof import("foo")` #[inline] pub fn ts_type_query_expr_name_import_type( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, + argument: TSType<'a>, + options: T1, qualifier: Option>, - attributes: T1, - type_parameters: T2, + type_arguments: T2, + is_type_of: bool, ) -> TSTypeQueryExprName<'a> where T1: IntoIn<'a, Option>>>, @@ -13443,11 +13443,11 @@ impl<'a> AstBuilder<'a> { { TSTypeQueryExprName::TSImportType(self.alloc_ts_import_type( span, - is_type_of, - parameter, + argument, + options, qualifier, - attributes, - type_parameters, + type_arguments, + is_type_of, )) } @@ -13457,20 +13457,20 @@ impl<'a> AstBuilder<'a> { /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` + /// * `argument` + /// * `options` /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `type_arguments` + /// * `is_type_of`: `true` for `typeof import("foo")` #[inline] pub fn ts_import_type( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, + argument: TSType<'a>, + options: T1, qualifier: Option>, - attributes: T1, - type_parameters: T2, + type_arguments: T2, + is_type_of: bool, ) -> TSImportType<'a> where T1: IntoIn<'a, Option>>>, @@ -13478,11 +13478,11 @@ impl<'a> AstBuilder<'a> { { TSImportType { span, - is_type_of, - parameter, + argument, + options: options.into_in(self.allocator), qualifier, - attributes: attributes.into_in(self.allocator), - type_parameters: type_parameters.into_in(self.allocator), + type_arguments: type_arguments.into_in(self.allocator), + is_type_of, } } @@ -13492,34 +13492,27 @@ impl<'a> AstBuilder<'a> { /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` + /// * `argument` + /// * `options` /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `type_arguments` + /// * `is_type_of`: `true` for `typeof import("foo")` #[inline] pub fn alloc_ts_import_type( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, + argument: TSType<'a>, + options: T1, qualifier: Option>, - attributes: T1, - type_parameters: T2, + type_arguments: T2, + is_type_of: bool, ) -> Box<'a, TSImportType<'a>> where T1: IntoIn<'a, Option>>>, T2: IntoIn<'a, Option>>>, { Box::new_in( - self.ts_import_type( - span, - is_type_of, - parameter, - qualifier, - attributes, - type_parameters, - ), + self.ts_import_type(span, argument, options, qualifier, type_arguments, is_type_of), self.allocator, ) } diff --git a/crates/oxc_ast/src/generated/derive_clone_in.rs b/crates/oxc_ast/src/generated/derive_clone_in.rs index c9d997c23c126..27aae72a3cd79 100644 --- a/crates/oxc_ast/src/generated/derive_clone_in.rs +++ b/crates/oxc_ast/src/generated/derive_clone_in.rs @@ -3849,11 +3849,11 @@ impl<'new_alloc> CloneIn<'new_alloc> for TSImportType<'_> { fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { TSImportType { span: CloneIn::clone_in(&self.span, allocator), - is_type_of: CloneIn::clone_in(&self.is_type_of, allocator), - parameter: CloneIn::clone_in(&self.parameter, allocator), + argument: CloneIn::clone_in(&self.argument, allocator), + options: CloneIn::clone_in(&self.options, allocator), qualifier: CloneIn::clone_in(&self.qualifier, allocator), - attributes: CloneIn::clone_in(&self.attributes, allocator), - type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), + type_arguments: CloneIn::clone_in(&self.type_arguments, allocator), + is_type_of: CloneIn::clone_in(&self.is_type_of, allocator), } } } diff --git a/crates/oxc_ast/src/generated/derive_content_eq.rs b/crates/oxc_ast/src/generated/derive_content_eq.rs index 04b365fea0536..1054d6e262cfd 100644 --- a/crates/oxc_ast/src/generated/derive_content_eq.rs +++ b/crates/oxc_ast/src/generated/derive_content_eq.rs @@ -2297,11 +2297,11 @@ impl ContentEq for TSTypeQueryExprName<'_> { impl ContentEq for TSImportType<'_> { fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.is_type_of, &other.is_type_of) - && ContentEq::content_eq(&self.parameter, &other.parameter) + ContentEq::content_eq(&self.argument, &other.argument) + && ContentEq::content_eq(&self.options, &other.options) && ContentEq::content_eq(&self.qualifier, &other.qualifier) - && ContentEq::content_eq(&self.attributes, &other.attributes) - && ContentEq::content_eq(&self.type_parameters, &other.type_parameters) + && ContentEq::content_eq(&self.type_arguments, &other.type_arguments) + && ContentEq::content_eq(&self.is_type_of, &other.is_type_of) } } diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index ba5fc003d1c5a..b99c265eee44b 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -3091,11 +3091,11 @@ impl ESTree for TSImportType<'_> { state.serialize_field("type", &JsonSafeString("TSImportType")); state.serialize_field("start", &self.span.start); state.serialize_field("end", &self.span.end); - state.serialize_field("isTypeOf", &self.is_type_of); - state.serialize_field("parameter", &self.parameter); + state.serialize_field("argument", &self.argument); + state.serialize_field("options", &self.options); state.serialize_field("qualifier", &self.qualifier); - state.serialize_field("attributes", &self.attributes); - state.serialize_field("typeParameters", &self.type_parameters); + state.serialize_field("typeArguments", &self.type_arguments); + state.serialize_field("isTypeOf", &self.is_type_of); state.end(); } } diff --git a/crates/oxc_ast_visit/src/generated/visit.rs b/crates/oxc_ast_visit/src/generated/visit.rs index 94122d0bb61ab..9ca23fa06433f 100644 --- a/crates/oxc_ast_visit/src/generated/visit.rs +++ b/crates/oxc_ast_visit/src/generated/visit.rs @@ -3909,15 +3909,15 @@ pub mod walk { let kind = AstKind::TSImportType(visitor.alloc(it)); visitor.enter_node(kind); visitor.visit_span(&it.span); - visitor.visit_ts_type(&it.parameter); + visitor.visit_ts_type(&it.argument); + if let Some(options) = &it.options { + visitor.visit_ts_import_attributes(options); + } if let Some(qualifier) = &it.qualifier { visitor.visit_ts_type_name(qualifier); } - if let Some(attributes) = &it.attributes { - visitor.visit_ts_import_attributes(attributes); - } - if let Some(type_parameters) = &it.type_parameters { - visitor.visit_ts_type_parameter_instantiation(type_parameters); + if let Some(type_arguments) = &it.type_arguments { + visitor.visit_ts_type_parameter_instantiation(type_arguments); } 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 f142774d0611c..71ee6392a26fd 100644 --- a/crates/oxc_ast_visit/src/generated/visit_mut.rs +++ b/crates/oxc_ast_visit/src/generated/visit_mut.rs @@ -4118,15 +4118,15 @@ pub mod walk_mut { let kind = AstType::TSImportType; visitor.enter_node(kind); visitor.visit_span(&mut it.span); - visitor.visit_ts_type(&mut it.parameter); + visitor.visit_ts_type(&mut it.argument); + if let Some(options) = &mut it.options { + visitor.visit_ts_import_attributes(options); + } if let Some(qualifier) = &mut it.qualifier { visitor.visit_ts_type_name(qualifier); } - if let Some(attributes) = &mut it.attributes { - visitor.visit_ts_import_attributes(attributes); - } - if let Some(type_parameters) = &mut it.type_parameters { - visitor.visit_ts_type_parameter_instantiation(type_parameters); + if let Some(type_arguments) = &mut it.type_arguments { + visitor.visit_ts_type_parameter_instantiation(type_arguments); } visitor.leave_node(kind); } diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 81d038d471d91..30ba2941bcd4b 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -3548,8 +3548,8 @@ impl Gen for TSImportType<'_> { p.print_str("typeof "); } p.print_str("import("); - self.parameter.print(p, ctx); - if let Some(attributes) = &self.attributes { + self.argument.print(p, ctx); + if let Some(attributes) = &self.options { p.print_str(", "); attributes.print(p, ctx); } @@ -3558,7 +3558,7 @@ impl Gen for TSImportType<'_> { p.print_ascii_byte(b'.'); qualifier.print(p, ctx); } - if let Some(type_parameters) = &self.type_parameters { + if let Some(type_parameters) = &self.type_arguments { type_parameters.print(p, ctx); } } diff --git a/crates/oxc_parser/src/ts/types.rs b/crates/oxc_parser/src/ts/types.rs index 71b9585cf4b75..3f3e7eb547904 100644 --- a/crates/oxc_parser/src/ts/types.rs +++ b/crates/oxc_parser/src/ts/types.rs @@ -980,19 +980,19 @@ impl<'a> ParserImpl<'a> { let is_type_of = self.eat(Kind::Typeof); self.expect(Kind::Import)?; self.expect(Kind::LParen)?; - let parameter = self.parse_ts_type()?; - let attributes = + let argument = self.parse_ts_type()?; + let options = if self.eat(Kind::Comma) { Some(self.parse_ts_import_attributes()?) } else { None }; self.expect(Kind::RParen)?; let qualifier = if self.eat(Kind::Dot) { Some(self.parse_ts_type_name()?) } else { None }; - let type_parameters = self.parse_type_arguments_of_type_reference()?; + let type_arguments = self.parse_type_arguments_of_type_reference()?; Ok(self.ast.ts_type_import_type( self.end_span(span), - is_type_of, - parameter, + argument, + options, qualifier, - attributes, - type_parameters, + type_arguments, + is_type_of, )) } diff --git a/crates/oxc_prettier/src/format/typescript.rs b/crates/oxc_prettier/src/format/typescript.rs index ab5ed3334489d..441708bd12e8d 100644 --- a/crates/oxc_prettier/src/format/typescript.rs +++ b/crates/oxc_prettier/src/format/typescript.rs @@ -244,7 +244,7 @@ impl<'a> Format<'a> for TSImportType<'a> { } parts.push(text!("import(")); - parts.push(self.parameter.format(p)); + parts.push(self.argument.format(p)); // ToDo: attributes parts.push(text!(")")); @@ -253,7 +253,7 @@ impl<'a> Format<'a> for TSImportType<'a> { parts.push(qualifier.format(p)); } - if let Some(type_parameters) = &self.type_parameters { + if let Some(type_parameters) = &self.type_arguments { parts.push(type_parameters.format(p)); } diff --git a/crates/oxc_traverse/src/generated/ancestor.rs b/crates/oxc_traverse/src/generated/ancestor.rs index 16e5996c6a553..e57c350f3d165 100644 --- a/crates/oxc_traverse/src/generated/ancestor.rs +++ b/crates/oxc_traverse/src/generated/ancestor.rs @@ -281,10 +281,10 @@ pub(crate) enum AncestorType { TSInferTypeTypeParameter = 258, TSTypeQueryExprName = 259, TSTypeQueryTypeParameters = 260, - TSImportTypeParameter = 261, - TSImportTypeQualifier = 262, - TSImportTypeAttributes = 263, - TSImportTypeTypeParameters = 264, + TSImportTypeArgument = 261, + TSImportTypeOptions = 262, + TSImportTypeQualifier = 263, + TSImportTypeTypeArguments = 264, TSImportAttributesAttributesKeyword = 265, TSImportAttributesElements = 266, TSImportAttributeName = 267, @@ -821,14 +821,14 @@ pub enum Ancestor<'a, 't> { AncestorType::TSTypeQueryExprName as u16, TSTypeQueryTypeParameters(TSTypeQueryWithoutTypeParameters<'a, 't>) = AncestorType::TSTypeQueryTypeParameters as u16, - TSImportTypeParameter(TSImportTypeWithoutParameter<'a, 't>) = - AncestorType::TSImportTypeParameter as u16, + TSImportTypeArgument(TSImportTypeWithoutArgument<'a, 't>) = + AncestorType::TSImportTypeArgument as u16, + TSImportTypeOptions(TSImportTypeWithoutOptions<'a, 't>) = + AncestorType::TSImportTypeOptions as u16, TSImportTypeQualifier(TSImportTypeWithoutQualifier<'a, 't>) = AncestorType::TSImportTypeQualifier as u16, - TSImportTypeAttributes(TSImportTypeWithoutAttributes<'a, 't>) = - AncestorType::TSImportTypeAttributes as u16, - TSImportTypeTypeParameters(TSImportTypeWithoutTypeParameters<'a, 't>) = - AncestorType::TSImportTypeTypeParameters as u16, + TSImportTypeTypeArguments(TSImportTypeWithoutTypeArguments<'a, 't>) = + AncestorType::TSImportTypeTypeArguments as u16, TSImportAttributesAttributesKeyword(TSImportAttributesWithoutAttributesKeyword<'a, 't>) = AncestorType::TSImportAttributesAttributesKeyword as u16, TSImportAttributesElements(TSImportAttributesWithoutElements<'a, 't>) = @@ -1749,10 +1749,10 @@ impl<'a, 't> Ancestor<'a, 't> { pub fn is_ts_import_type(self) -> bool { matches!( self, - Self::TSImportTypeParameter(_) + Self::TSImportTypeArgument(_) + | Self::TSImportTypeOptions(_) | Self::TSImportTypeQualifier(_) - | Self::TSImportTypeAttributes(_) - | Self::TSImportTypeTypeParameters(_) + | Self::TSImportTypeTypeArguments(_) ) } @@ -2146,7 +2146,7 @@ impl<'a, 't> Ancestor<'a, 't> { | Self::TSTypeParameterConstraint(_) | Self::TSTypeParameterDefault(_) | Self::TSTypeAliasDeclarationTypeAnnotation(_) - | Self::TSImportTypeParameter(_) + | Self::TSImportTypeArgument(_) | Self::TSMappedTypeNameType(_) | Self::TSMappedTypeTypeAnnotation(_) | Self::TSTemplateLiteralTypeTypes(_) @@ -2482,10 +2482,10 @@ impl<'a, 't> GetAddress for Ancestor<'a, 't> { Self::TSInferTypeTypeParameter(a) => a.address(), Self::TSTypeQueryExprName(a) => a.address(), Self::TSTypeQueryTypeParameters(a) => a.address(), - Self::TSImportTypeParameter(a) => a.address(), + Self::TSImportTypeArgument(a) => a.address(), + Self::TSImportTypeOptions(a) => a.address(), Self::TSImportTypeQualifier(a) => a.address(), - Self::TSImportTypeAttributes(a) => a.address(), - Self::TSImportTypeTypeParameters(a) => a.address(), + Self::TSImportTypeTypeArguments(a) => a.address(), Self::TSImportAttributesAttributesKeyword(a) => a.address(), Self::TSImportAttributesElements(a) => a.address(), Self::TSImportAttributeName(a) => a.address(), @@ -14247,29 +14247,32 @@ impl<'a, 't> GetAddress for TSTypeQueryWithoutTypeParameters<'a, 't> { } pub(crate) const OFFSET_TS_IMPORT_TYPE_SPAN: usize = offset_of!(TSImportType, span); -pub(crate) const OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF: usize = offset_of!(TSImportType, is_type_of); -pub(crate) const OFFSET_TS_IMPORT_TYPE_PARAMETER: usize = offset_of!(TSImportType, parameter); +pub(crate) const OFFSET_TS_IMPORT_TYPE_ARGUMENT: usize = offset_of!(TSImportType, argument); +pub(crate) const OFFSET_TS_IMPORT_TYPE_OPTIONS: usize = offset_of!(TSImportType, options); pub(crate) const OFFSET_TS_IMPORT_TYPE_QUALIFIER: usize = offset_of!(TSImportType, qualifier); -pub(crate) const OFFSET_TS_IMPORT_TYPE_ATTRIBUTES: usize = offset_of!(TSImportType, attributes); -pub(crate) const OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS: usize = - offset_of!(TSImportType, type_parameters); +pub(crate) const OFFSET_TS_IMPORT_TYPE_TYPE_ARGUMENTS: usize = + offset_of!(TSImportType, type_arguments); +pub(crate) const OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF: usize = offset_of!(TSImportType, is_type_of); #[repr(transparent)] #[derive(Clone, Copy, Debug)] -pub struct TSImportTypeWithoutParameter<'a, 't>( +pub struct TSImportTypeWithoutArgument<'a, 't>( pub(crate) *const TSImportType<'a>, pub(crate) PhantomData<&'t ()>, ); -impl<'a, 't> TSImportTypeWithoutParameter<'a, 't> { +impl<'a, 't> TSImportTypeWithoutArgument<'a, 't> { #[inline] pub fn span(self) -> &'t Span { unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } } #[inline] - pub fn is_type_of(self) -> &'t bool { - unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } + pub fn options(self) -> &'t Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_OPTIONS) + as *const Option>>) + } } #[inline] @@ -14281,23 +14284,20 @@ impl<'a, 't> TSImportTypeWithoutParameter<'a, 't> { } #[inline] - pub fn attributes(self) -> &'t Option>> { + pub fn type_arguments(self) -> &'t Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_ARGUMENTS) + as *const Option>>) } } #[inline] - pub fn type_parameters(self) -> &'t Option>> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) - as *const Option>>) - } + pub fn is_type_of(self) -> &'t bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } } } -impl<'a, 't> GetAddress for TSImportTypeWithoutParameter<'a, 't> { +impl<'a, 't> GetAddress for TSImportTypeWithoutArgument<'a, 't> { #[inline] fn address(&self) -> Address { Address::from_ptr(self.0) @@ -14306,47 +14306,47 @@ impl<'a, 't> GetAddress for TSImportTypeWithoutParameter<'a, 't> { #[repr(transparent)] #[derive(Clone, Copy, Debug)] -pub struct TSImportTypeWithoutQualifier<'a, 't>( +pub struct TSImportTypeWithoutOptions<'a, 't>( pub(crate) *const TSImportType<'a>, pub(crate) PhantomData<&'t ()>, ); -impl<'a, 't> TSImportTypeWithoutQualifier<'a, 't> { +impl<'a, 't> TSImportTypeWithoutOptions<'a, 't> { #[inline] pub fn span(self) -> &'t Span { unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } } #[inline] - pub fn is_type_of(self) -> &'t bool { - unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } - } - - #[inline] - pub fn parameter(self) -> &'t TSType<'a> { + pub fn argument(self) -> &'t TSType<'a> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_PARAMETER) as *const TSType<'a>) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *const TSType<'a>) } } #[inline] - pub fn attributes(self) -> &'t Option>> { + pub fn qualifier(self) -> &'t Option> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) - as *const Option>>) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_QUALIFIER) + as *const Option>) } } #[inline] - pub fn type_parameters(self) -> &'t Option>> { + pub fn type_arguments(self) -> &'t Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_ARGUMENTS) as *const Option>>) } } + + #[inline] + pub fn is_type_of(self) -> &'t bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } + } } -impl<'a, 't> GetAddress for TSImportTypeWithoutQualifier<'a, 't> { +impl<'a, 't> GetAddress for TSImportTypeWithoutOptions<'a, 't> { #[inline] fn address(&self) -> Address { Address::from_ptr(self.0) @@ -14355,47 +14355,47 @@ impl<'a, 't> GetAddress for TSImportTypeWithoutQualifier<'a, 't> { #[repr(transparent)] #[derive(Clone, Copy, Debug)] -pub struct TSImportTypeWithoutAttributes<'a, 't>( +pub struct TSImportTypeWithoutQualifier<'a, 't>( pub(crate) *const TSImportType<'a>, pub(crate) PhantomData<&'t ()>, ); -impl<'a, 't> TSImportTypeWithoutAttributes<'a, 't> { +impl<'a, 't> TSImportTypeWithoutQualifier<'a, 't> { #[inline] pub fn span(self) -> &'t Span { unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } } #[inline] - pub fn is_type_of(self) -> &'t bool { - unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } - } - - #[inline] - pub fn parameter(self) -> &'t TSType<'a> { + pub fn argument(self) -> &'t TSType<'a> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_PARAMETER) as *const TSType<'a>) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *const TSType<'a>) } } #[inline] - pub fn qualifier(self) -> &'t Option> { + pub fn options(self) -> &'t Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_QUALIFIER) - as *const Option>) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_OPTIONS) + as *const Option>>) } } #[inline] - pub fn type_parameters(self) -> &'t Option>> { + pub fn type_arguments(self) -> &'t Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_ARGUMENTS) as *const Option>>) } } + + #[inline] + pub fn is_type_of(self) -> &'t bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } + } } -impl<'a, 't> GetAddress for TSImportTypeWithoutAttributes<'a, 't> { +impl<'a, 't> GetAddress for TSImportTypeWithoutQualifier<'a, 't> { #[inline] fn address(&self) -> Address { Address::from_ptr(self.0) @@ -14404,26 +14404,29 @@ impl<'a, 't> GetAddress for TSImportTypeWithoutAttributes<'a, 't> { #[repr(transparent)] #[derive(Clone, Copy, Debug)] -pub struct TSImportTypeWithoutTypeParameters<'a, 't>( +pub struct TSImportTypeWithoutTypeArguments<'a, 't>( pub(crate) *const TSImportType<'a>, pub(crate) PhantomData<&'t ()>, ); -impl<'a, 't> TSImportTypeWithoutTypeParameters<'a, 't> { +impl<'a, 't> TSImportTypeWithoutTypeArguments<'a, 't> { #[inline] pub fn span(self) -> &'t Span { unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } } #[inline] - pub fn is_type_of(self) -> &'t bool { - unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } + pub fn argument(self) -> &'t TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *const TSType<'a>) + } } #[inline] - pub fn parameter(self) -> &'t TSType<'a> { + pub fn options(self) -> &'t Option>> { unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_PARAMETER) as *const TSType<'a>) + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_OPTIONS) + as *const Option>>) } } @@ -14436,15 +14439,12 @@ impl<'a, 't> TSImportTypeWithoutTypeParameters<'a, 't> { } #[inline] - pub fn attributes(self) -> &'t Option>> { - unsafe { - &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) - as *const Option>>) - } + pub fn is_type_of(self) -> &'t bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_IS_TYPE_OF) as *const bool) } } } -impl<'a, 't> GetAddress for TSImportTypeWithoutTypeParameters<'a, 't> { +impl<'a, 't> GetAddress for TSImportTypeWithoutTypeArguments<'a, 't> { #[inline] fn address(&self) -> Address { Address::from_ptr(self.0) diff --git a/crates/oxc_traverse/src/generated/walk.rs b/crates/oxc_traverse/src/generated/walk.rs index e2c3973179eb1..55cc8ae6c84fb 100644 --- a/crates/oxc_traverse/src/generated/walk.rs +++ b/crates/oxc_traverse/src/generated/walk.rs @@ -5122,31 +5122,31 @@ unsafe fn walk_ts_import_type<'a, Tr: Traverse<'a>>( ctx: &mut TraverseCtx<'a>, ) { traverser.enter_ts_import_type(&mut *node, ctx); - let pop_token = ctx.push_stack(Ancestor::TSImportTypeParameter( - ancestor::TSImportTypeWithoutParameter(node, PhantomData), + let pop_token = ctx.push_stack(Ancestor::TSImportTypeArgument( + ancestor::TSImportTypeWithoutArgument(node, PhantomData), )); walk_ts_type( traverser, - (node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_PARAMETER) as *mut TSType, + (node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *mut TSType, ctx, ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_OPTIONS) + as *mut Option>) + { + ctx.retag_stack(AncestorType::TSImportTypeOptions); + walk_ts_import_attributes(traverser, (&mut **field) as *mut _, ctx); + } if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_QUALIFIER) as *mut Option) { ctx.retag_stack(AncestorType::TSImportTypeQualifier); walk_ts_type_name(traverser, field as *mut _, ctx); } - if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) - as *mut Option>) - { - ctx.retag_stack(AncestorType::TSImportTypeAttributes); - walk_ts_import_attributes(traverser, (&mut **field) as *mut _, ctx); - } if let Some(field) = &mut *((node as *mut u8) - .add(ancestor::OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) + .add(ancestor::OFFSET_TS_IMPORT_TYPE_TYPE_ARGUMENTS) as *mut Option>) { - ctx.retag_stack(AncestorType::TSImportTypeTypeParameters); + ctx.retag_stack(AncestorType::TSImportTypeTypeArguments); walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); } ctx.pop_stack(pop_token); diff --git a/napi/parser/deserialize-js.js b/napi/parser/deserialize-js.js index f4ae52a99bf86..8d0d3904a23f8 100644 --- a/napi/parser/deserialize-js.js +++ b/napi/parser/deserialize-js.js @@ -1771,11 +1771,11 @@ function deserializeTSImportType(pos) { type: 'TSImportType', start: deserializeU32(pos), end: deserializeU32(pos + 4), - isTypeOf: deserializeBool(pos + 8), - parameter: deserializeTSType(pos + 16), + argument: deserializeTSType(pos + 8), + options: deserializeOptionBoxTSImportAttributes(pos + 24), qualifier: deserializeOptionTSTypeName(pos + 32), - attributes: deserializeOptionBoxTSImportAttributes(pos + 48), - typeParameters: deserializeOptionBoxTSTypeParameterInstantiation(pos + 56), + typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48), + isTypeOf: deserializeBool(pos + 56), }; } @@ -5515,11 +5515,6 @@ function deserializeBoxTSTypeParameter(pos) { return deserializeTSTypeParameter(uint32[pos >> 2]); } -function deserializeOptionTSTypeName(pos) { - if (uint8[pos] === 2) return null; - return deserializeTSTypeName(pos); -} - function deserializeBoxTSImportAttributes(pos) { return deserializeTSImportAttributes(uint32[pos >> 2]); } @@ -5529,6 +5524,11 @@ function deserializeOptionBoxTSImportAttributes(pos) { return deserializeBoxTSImportAttributes(pos); } +function deserializeOptionTSTypeName(pos) { + if (uint8[pos] === 2) return null; + return deserializeTSTypeName(pos); +} + function deserializeVecTSImportAttribute(pos) { const arr = [], pos32 = pos >> 2, diff --git a/napi/parser/deserialize-ts.js b/napi/parser/deserialize-ts.js index e11d370f7c1af..83f9ae0c2bc4a 100644 --- a/napi/parser/deserialize-ts.js +++ b/napi/parser/deserialize-ts.js @@ -1824,11 +1824,11 @@ function deserializeTSImportType(pos) { type: 'TSImportType', start: deserializeU32(pos), end: deserializeU32(pos + 4), - isTypeOf: deserializeBool(pos + 8), - parameter: deserializeTSType(pos + 16), + argument: deserializeTSType(pos + 8), + options: deserializeOptionBoxTSImportAttributes(pos + 24), qualifier: deserializeOptionTSTypeName(pos + 32), - attributes: deserializeOptionBoxTSImportAttributes(pos + 48), - typeParameters: deserializeOptionBoxTSTypeParameterInstantiation(pos + 56), + typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48), + isTypeOf: deserializeBool(pos + 56), }; } @@ -5568,11 +5568,6 @@ function deserializeBoxTSTypeParameter(pos) { return deserializeTSTypeParameter(uint32[pos >> 2]); } -function deserializeOptionTSTypeName(pos) { - if (uint8[pos] === 2) return null; - return deserializeTSTypeName(pos); -} - function deserializeBoxTSImportAttributes(pos) { return deserializeTSImportAttributes(uint32[pos >> 2]); } @@ -5582,6 +5577,11 @@ function deserializeOptionBoxTSImportAttributes(pos) { return deserializeBoxTSImportAttributes(pos); } +function deserializeOptionTSTypeName(pos) { + if (uint8[pos] === 2) return null; + return deserializeTSTypeName(pos); +} + function deserializeVecTSImportAttribute(pos) { const arr = [], pos32 = pos >> 2, diff --git a/npm/oxc-types/types.d.ts b/npm/oxc-types/types.d.ts index 509218f4a4ab0..29fb629d2e1a8 100644 --- a/npm/oxc-types/types.d.ts +++ b/npm/oxc-types/types.d.ts @@ -1281,11 +1281,11 @@ export type TSTypeQueryExprName = TSImportType | TSTypeName; export interface TSImportType extends Span { type: 'TSImportType'; - isTypeOf: boolean; - parameter: TSType; + argument: TSType; + options: TSImportAttributes | null; qualifier: TSTypeName | null; - attributes: TSImportAttributes | null; - typeParameters: TSTypeParameterInstantiation | null; + typeArguments: TSTypeParameterInstantiation | null; + isTypeOf: boolean; } export interface TSImportAttributes extends Span {