Skip to content

Commit f0ad4f0

Browse files
committed
fix(ast): align TSImportType field names with ts-eslint
1 parent 29edb51 commit f0ad4f0

File tree

16 files changed

+203
-210
lines changed

16 files changed

+203
-210
lines changed

crates/oxc_ast/src/ast/ts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,12 +1278,12 @@ pub enum TSTypeQueryExprName<'a> {
12781278
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
12791279
pub struct TSImportType<'a> {
12801280
pub span: Span,
1281+
pub argument: TSType<'a>,
1282+
pub options: Option<Box<'a, TSImportAttributes<'a>>>,
1283+
pub qualifier: Option<TSTypeName<'a>>,
1284+
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
12811285
/// `true` for `typeof import("foo")`
12821286
pub is_type_of: bool,
1283-
pub parameter: TSType<'a>,
1284-
pub qualifier: Option<TSTypeName<'a>>,
1285-
pub attributes: Option<Box<'a, TSImportAttributes<'a>>>,
1286-
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
12871287
}
12881288

12891289
#[ast(visit)]

crates/oxc_ast/src/generated/assert_layouts.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,11 +1256,11 @@ const _: () = {
12561256
assert!(size_of::<TSImportType>() == 64);
12571257
assert!(align_of::<TSImportType>() == 8);
12581258
assert!(offset_of!(TSImportType, span) == 0);
1259-
assert!(offset_of!(TSImportType, is_type_of) == 8);
1260-
assert!(offset_of!(TSImportType, parameter) == 16);
1259+
assert!(offset_of!(TSImportType, argument) == 8);
1260+
assert!(offset_of!(TSImportType, options) == 24);
12611261
assert!(offset_of!(TSImportType, qualifier) == 32);
1262-
assert!(offset_of!(TSImportType, attributes) == 48);
1263-
assert!(offset_of!(TSImportType, type_parameters) == 56);
1262+
assert!(offset_of!(TSImportType, type_arguments) == 48);
1263+
assert!(offset_of!(TSImportType, is_type_of) == 56);
12641264

12651265
assert!(size_of::<TSImportAttributes>() == 64);
12661266
assert!(align_of::<TSImportAttributes>() == 8);
@@ -2660,11 +2660,11 @@ const _: () = {
26602660
assert!(size_of::<TSImportType>() == 36);
26612661
assert!(align_of::<TSImportType>() == 4);
26622662
assert!(offset_of!(TSImportType, span) == 0);
2663-
assert!(offset_of!(TSImportType, is_type_of) == 8);
2664-
assert!(offset_of!(TSImportType, parameter) == 12);
2663+
assert!(offset_of!(TSImportType, argument) == 8);
2664+
assert!(offset_of!(TSImportType, options) == 16);
26652665
assert!(offset_of!(TSImportType, qualifier) == 20);
2666-
assert!(offset_of!(TSImportType, attributes) == 28);
2667-
assert!(offset_of!(TSImportType, type_parameters) == 32);
2666+
assert!(offset_of!(TSImportType, type_arguments) == 28);
2667+
assert!(offset_of!(TSImportType, is_type_of) == 32);
26682668

26692669
assert!(size_of::<TSImportAttributes>() == 40);
26702670
assert!(align_of::<TSImportAttributes>() == 4);

crates/oxc_ast/src/generated/ast_builder.rs

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10306,32 +10306,32 @@ impl<'a> AstBuilder<'a> {
1030610306
///
1030710307
/// ## Parameters
1030810308
/// * `span`: The [`Span`] covering this node
10309-
/// * `is_type_of`: `true` for `typeof import("foo")`
10310-
/// * `parameter`
10309+
/// * `argument`
10310+
/// * `options`
1031110311
/// * `qualifier`
10312-
/// * `attributes`
10313-
/// * `type_parameters`
10312+
/// * `type_arguments`
10313+
/// * `is_type_of`: `true` for `typeof import("foo")`
1031410314
#[inline]
1031510315
pub fn ts_type_import_type<T1, T2>(
1031610316
self,
1031710317
span: Span,
10318-
is_type_of: bool,
10319-
parameter: TSType<'a>,
10318+
argument: TSType<'a>,
10319+
options: T1,
1032010320
qualifier: Option<TSTypeName<'a>>,
10321-
attributes: T1,
10322-
type_parameters: T2,
10321+
type_arguments: T2,
10322+
is_type_of: bool,
1032310323
) -> TSType<'a>
1032410324
where
1032510325
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
1032610326
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
1032710327
{
1032810328
TSType::TSImportType(self.alloc_ts_import_type(
1032910329
span,
10330-
is_type_of,
10331-
parameter,
10330+
argument,
10331+
options,
1033210332
qualifier,
10333-
attributes,
10334-
type_parameters,
10333+
type_arguments,
10334+
is_type_of,
1033510335
))
1033610336
}
1033710337

@@ -13422,32 +13422,32 @@ impl<'a> AstBuilder<'a> {
1342213422
///
1342313423
/// ## Parameters
1342413424
/// * `span`: The [`Span`] covering this node
13425-
/// * `is_type_of`: `true` for `typeof import("foo")`
13426-
/// * `parameter`
13425+
/// * `argument`
13426+
/// * `options`
1342713427
/// * `qualifier`
13428-
/// * `attributes`
13429-
/// * `type_parameters`
13428+
/// * `type_arguments`
13429+
/// * `is_type_of`: `true` for `typeof import("foo")`
1343013430
#[inline]
1343113431
pub fn ts_type_query_expr_name_import_type<T1, T2>(
1343213432
self,
1343313433
span: Span,
13434-
is_type_of: bool,
13435-
parameter: TSType<'a>,
13434+
argument: TSType<'a>,
13435+
options: T1,
1343613436
qualifier: Option<TSTypeName<'a>>,
13437-
attributes: T1,
13438-
type_parameters: T2,
13437+
type_arguments: T2,
13438+
is_type_of: bool,
1343913439
) -> TSTypeQueryExprName<'a>
1344013440
where
1344113441
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
1344213442
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
1344313443
{
1344413444
TSTypeQueryExprName::TSImportType(self.alloc_ts_import_type(
1344513445
span,
13446-
is_type_of,
13447-
parameter,
13446+
argument,
13447+
options,
1344813448
qualifier,
13449-
attributes,
13450-
type_parameters,
13449+
type_arguments,
13450+
is_type_of,
1345113451
))
1345213452
}
1345313453

@@ -13457,32 +13457,32 @@ impl<'a> AstBuilder<'a> {
1345713457
///
1345813458
/// ## Parameters
1345913459
/// * `span`: The [`Span`] covering this node
13460-
/// * `is_type_of`: `true` for `typeof import("foo")`
13461-
/// * `parameter`
13460+
/// * `argument`
13461+
/// * `options`
1346213462
/// * `qualifier`
13463-
/// * `attributes`
13464-
/// * `type_parameters`
13463+
/// * `type_arguments`
13464+
/// * `is_type_of`: `true` for `typeof import("foo")`
1346513465
#[inline]
1346613466
pub fn ts_import_type<T1, T2>(
1346713467
self,
1346813468
span: Span,
13469-
is_type_of: bool,
13470-
parameter: TSType<'a>,
13469+
argument: TSType<'a>,
13470+
options: T1,
1347113471
qualifier: Option<TSTypeName<'a>>,
13472-
attributes: T1,
13473-
type_parameters: T2,
13472+
type_arguments: T2,
13473+
is_type_of: bool,
1347413474
) -> TSImportType<'a>
1347513475
where
1347613476
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
1347713477
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
1347813478
{
1347913479
TSImportType {
1348013480
span,
13481-
is_type_of,
13482-
parameter,
13481+
argument,
13482+
options: options.into_in(self.allocator),
1348313483
qualifier,
13484-
attributes: attributes.into_in(self.allocator),
13485-
type_parameters: type_parameters.into_in(self.allocator),
13484+
type_arguments: type_arguments.into_in(self.allocator),
13485+
is_type_of,
1348613486
}
1348713487
}
1348813488

@@ -13492,34 +13492,27 @@ impl<'a> AstBuilder<'a> {
1349213492
///
1349313493
/// ## Parameters
1349413494
/// * `span`: The [`Span`] covering this node
13495-
/// * `is_type_of`: `true` for `typeof import("foo")`
13496-
/// * `parameter`
13495+
/// * `argument`
13496+
/// * `options`
1349713497
/// * `qualifier`
13498-
/// * `attributes`
13499-
/// * `type_parameters`
13498+
/// * `type_arguments`
13499+
/// * `is_type_of`: `true` for `typeof import("foo")`
1350013500
#[inline]
1350113501
pub fn alloc_ts_import_type<T1, T2>(
1350213502
self,
1350313503
span: Span,
13504-
is_type_of: bool,
13505-
parameter: TSType<'a>,
13504+
argument: TSType<'a>,
13505+
options: T1,
1350613506
qualifier: Option<TSTypeName<'a>>,
13507-
attributes: T1,
13508-
type_parameters: T2,
13507+
type_arguments: T2,
13508+
is_type_of: bool,
1350913509
) -> Box<'a, TSImportType<'a>>
1351013510
where
1351113511
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
1351213512
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
1351313513
{
1351413514
Box::new_in(
13515-
self.ts_import_type(
13516-
span,
13517-
is_type_of,
13518-
parameter,
13519-
qualifier,
13520-
attributes,
13521-
type_parameters,
13522-
),
13515+
self.ts_import_type(span, argument, options, qualifier, type_arguments, is_type_of),
1352313516
self.allocator,
1352413517
)
1352513518
}

crates/oxc_ast/src/generated/derive_clone_in.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3849,11 +3849,11 @@ impl<'new_alloc> CloneIn<'new_alloc> for TSImportType<'_> {
38493849
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
38503850
TSImportType {
38513851
span: CloneIn::clone_in(&self.span, allocator),
3852-
is_type_of: CloneIn::clone_in(&self.is_type_of, allocator),
3853-
parameter: CloneIn::clone_in(&self.parameter, allocator),
3852+
argument: CloneIn::clone_in(&self.argument, allocator),
3853+
options: CloneIn::clone_in(&self.options, allocator),
38543854
qualifier: CloneIn::clone_in(&self.qualifier, allocator),
3855-
attributes: CloneIn::clone_in(&self.attributes, allocator),
3856-
type_parameters: CloneIn::clone_in(&self.type_parameters, allocator),
3855+
type_arguments: CloneIn::clone_in(&self.type_arguments, allocator),
3856+
is_type_of: CloneIn::clone_in(&self.is_type_of, allocator),
38573857
}
38583858
}
38593859
}

crates/oxc_ast/src/generated/derive_content_eq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,11 +2297,11 @@ impl ContentEq for TSTypeQueryExprName<'_> {
22972297

22982298
impl ContentEq for TSImportType<'_> {
22992299
fn content_eq(&self, other: &Self) -> bool {
2300-
ContentEq::content_eq(&self.is_type_of, &other.is_type_of)
2301-
&& ContentEq::content_eq(&self.parameter, &other.parameter)
2300+
ContentEq::content_eq(&self.argument, &other.argument)
2301+
&& ContentEq::content_eq(&self.options, &other.options)
23022302
&& ContentEq::content_eq(&self.qualifier, &other.qualifier)
2303-
&& ContentEq::content_eq(&self.attributes, &other.attributes)
2304-
&& ContentEq::content_eq(&self.type_parameters, &other.type_parameters)
2303+
&& ContentEq::content_eq(&self.type_arguments, &other.type_arguments)
2304+
&& ContentEq::content_eq(&self.is_type_of, &other.is_type_of)
23052305
}
23062306
}
23072307

crates/oxc_ast/src/generated/derive_estree.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,11 +3091,11 @@ impl ESTree for TSImportType<'_> {
30913091
state.serialize_field("type", &JsonSafeString("TSImportType"));
30923092
state.serialize_field("start", &self.span.start);
30933093
state.serialize_field("end", &self.span.end);
3094-
state.serialize_field("isTypeOf", &self.is_type_of);
3095-
state.serialize_field("parameter", &self.parameter);
3094+
state.serialize_field("argument", &self.argument);
3095+
state.serialize_field("options", &self.options);
30963096
state.serialize_field("qualifier", &self.qualifier);
3097-
state.serialize_field("attributes", &self.attributes);
3098-
state.serialize_field("typeParameters", &self.type_parameters);
3097+
state.serialize_field("typeArguments", &self.type_arguments);
3098+
state.serialize_field("isTypeOf", &self.is_type_of);
30993099
state.end();
31003100
}
31013101
}

crates/oxc_ast_visit/src/generated/visit.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,15 +3909,15 @@ pub mod walk {
39093909
let kind = AstKind::TSImportType(visitor.alloc(it));
39103910
visitor.enter_node(kind);
39113911
visitor.visit_span(&it.span);
3912-
visitor.visit_ts_type(&it.parameter);
3912+
visitor.visit_ts_type(&it.argument);
3913+
if let Some(options) = &it.options {
3914+
visitor.visit_ts_import_attributes(options);
3915+
}
39133916
if let Some(qualifier) = &it.qualifier {
39143917
visitor.visit_ts_type_name(qualifier);
39153918
}
3916-
if let Some(attributes) = &it.attributes {
3917-
visitor.visit_ts_import_attributes(attributes);
3918-
}
3919-
if let Some(type_parameters) = &it.type_parameters {
3920-
visitor.visit_ts_type_parameter_instantiation(type_parameters);
3919+
if let Some(type_arguments) = &it.type_arguments {
3920+
visitor.visit_ts_type_parameter_instantiation(type_arguments);
39213921
}
39223922
visitor.leave_node(kind);
39233923
}

crates/oxc_ast_visit/src/generated/visit_mut.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4118,15 +4118,15 @@ pub mod walk_mut {
41184118
let kind = AstType::TSImportType;
41194119
visitor.enter_node(kind);
41204120
visitor.visit_span(&mut it.span);
4121-
visitor.visit_ts_type(&mut it.parameter);
4121+
visitor.visit_ts_type(&mut it.argument);
4122+
if let Some(options) = &mut it.options {
4123+
visitor.visit_ts_import_attributes(options);
4124+
}
41224125
if let Some(qualifier) = &mut it.qualifier {
41234126
visitor.visit_ts_type_name(qualifier);
41244127
}
4125-
if let Some(attributes) = &mut it.attributes {
4126-
visitor.visit_ts_import_attributes(attributes);
4127-
}
4128-
if let Some(type_parameters) = &mut it.type_parameters {
4129-
visitor.visit_ts_type_parameter_instantiation(type_parameters);
4128+
if let Some(type_arguments) = &mut it.type_arguments {
4129+
visitor.visit_ts_type_parameter_instantiation(type_arguments);
41304130
}
41314131
visitor.leave_node(kind);
41324132
}

crates/oxc_codegen/src/gen.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,8 +3548,8 @@ impl Gen for TSImportType<'_> {
35483548
p.print_str("typeof ");
35493549
}
35503550
p.print_str("import(");
3551-
self.parameter.print(p, ctx);
3552-
if let Some(attributes) = &self.attributes {
3551+
self.argument.print(p, ctx);
3552+
if let Some(attributes) = &self.options {
35533553
p.print_str(", ");
35543554
attributes.print(p, ctx);
35553555
}
@@ -3558,7 +3558,7 @@ impl Gen for TSImportType<'_> {
35583558
p.print_ascii_byte(b'.');
35593559
qualifier.print(p, ctx);
35603560
}
3561-
if let Some(type_parameters) = &self.type_parameters {
3561+
if let Some(type_parameters) = &self.type_arguments {
35623562
type_parameters.print(p, ctx);
35633563
}
35643564
}

crates/oxc_parser/src/ts/types.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -980,19 +980,19 @@ impl<'a> ParserImpl<'a> {
980980
let is_type_of = self.eat(Kind::Typeof);
981981
self.expect(Kind::Import)?;
982982
self.expect(Kind::LParen)?;
983-
let parameter = self.parse_ts_type()?;
984-
let attributes =
983+
let argument = self.parse_ts_type()?;
984+
let options =
985985
if self.eat(Kind::Comma) { Some(self.parse_ts_import_attributes()?) } else { None };
986986
self.expect(Kind::RParen)?;
987987
let qualifier = if self.eat(Kind::Dot) { Some(self.parse_ts_type_name()?) } else { None };
988-
let type_parameters = self.parse_type_arguments_of_type_reference()?;
988+
let type_arguments = self.parse_type_arguments_of_type_reference()?;
989989
Ok(self.ast.ts_type_import_type(
990990
self.end_span(span),
991-
is_type_of,
992-
parameter,
991+
argument,
992+
options,
993993
qualifier,
994-
attributes,
995-
type_parameters,
994+
type_arguments,
995+
is_type_of,
996996
))
997997
}
998998

0 commit comments

Comments
 (0)