Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<'a, TSImportAttributes<'a>>>,
pub qualifier: Option<TSTypeName<'a>>,
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
/// `true` for `typeof import("foo")`
pub is_type_of: bool,
pub parameter: TSType<'a>,
pub qualifier: Option<TSTypeName<'a>>,
pub attributes: Option<Box<'a, TSImportAttributes<'a>>>,
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}

#[ast(visit)]
Expand Down
16 changes: 8 additions & 8 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,11 +1256,11 @@ const _: () = {
assert!(size_of::<TSImportType>() == 64);
assert!(align_of::<TSImportType>() == 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::<TSImportAttributes>() == 64);
assert!(align_of::<TSImportAttributes>() == 8);
Expand Down Expand Up @@ -2660,11 +2660,11 @@ const _: () = {
assert!(size_of::<TSImportType>() == 36);
assert!(align_of::<TSImportType>() == 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::<TSImportAttributes>() == 40);
assert!(align_of::<TSImportAttributes>() == 4);
Expand Down
97 changes: 45 additions & 52 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10306,32 +10306,32 @@ 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<T1, T2>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
options: T1,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
type_arguments: T2,
is_type_of: bool,
) -> TSType<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
{
TSType::TSImportType(self.alloc_ts_import_type(
span,
is_type_of,
parameter,
argument,
options,
qualifier,
attributes,
type_parameters,
type_arguments,
is_type_of,
))
}

Expand Down Expand Up @@ -13422,32 +13422,32 @@ 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<T1, T2>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
options: T1,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
type_arguments: T2,
is_type_of: bool,
) -> TSTypeQueryExprName<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
{
TSTypeQueryExprName::TSImportType(self.alloc_ts_import_type(
span,
is_type_of,
parameter,
argument,
options,
qualifier,
attributes,
type_parameters,
type_arguments,
is_type_of,
))
}

Expand All @@ -13457,32 +13457,32 @@ 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<T1, T2>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
options: T1,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
type_arguments: T2,
is_type_of: bool,
) -> TSImportType<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'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,
}
}

Expand All @@ -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<T1, T2>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
options: T1,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
type_arguments: T2,
is_type_of: bool,
) -> Box<'a, TSImportType<'a>>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
{
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,
)
}
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/oxc_ast_visit/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions crates/oxc_ast_visit/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/oxc_parser/src/ts/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
))
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_prettier/src/format/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(")"));

Expand All @@ -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));
}

Expand Down
Loading
Loading