Skip to content

Commit 43156ae

Browse files
committed
feat(ast)!: rename TSImportType argument field to source (#16110)
Rename `argument` field of `TSImportType` to `source`. This matches TS-ESTree and also aligns with `ImportExpression`.
1 parent 91eb3f2 commit 43156ae

File tree

15 files changed

+50
-58
lines changed

15 files changed

+50
-58
lines changed

crates/oxc_ast/src/ast/ts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,8 @@ pub enum TSTypeQueryExprName<'a> {
13811381
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
13821382
pub struct TSImportType<'a> {
13831383
pub span: Span,
1384-
#[estree(rename = "source", via = TSImportTypeSource)]
1385-
pub argument: TSType<'a>,
1384+
#[estree(via = TSImportTypeSource)]
1385+
pub source: TSType<'a>,
13861386
pub options: Option<Box<'a, ObjectExpression<'a>>>,
13871387
pub qualifier: Option<TSImportTypeQualifier<'a>>,
13881388
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,

crates/oxc_ast/src/generated/assert_layouts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ const _: () = {
14521452
assert!(size_of::<TSImportType>() == 56);
14531453
assert!(align_of::<TSImportType>() == 8);
14541454
assert!(offset_of!(TSImportType, span) == 0);
1455-
assert!(offset_of!(TSImportType, argument) == 8);
1455+
assert!(offset_of!(TSImportType, source) == 8);
14561456
assert!(offset_of!(TSImportType, options) == 24);
14571457
assert!(offset_of!(TSImportType, qualifier) == 32);
14581458
assert!(offset_of!(TSImportType, type_arguments) == 48);
@@ -3068,7 +3068,7 @@ const _: () = if cfg!(target_family = "wasm") || align_of::<u64>() == 8 {
30683068
assert!(size_of::<TSImportType>() == 32);
30693069
assert!(align_of::<TSImportType>() == 4);
30703070
assert!(offset_of!(TSImportType, span) == 0);
3071-
assert!(offset_of!(TSImportType, argument) == 8);
3071+
assert!(offset_of!(TSImportType, source) == 8);
30723072
assert!(offset_of!(TSImportType, options) == 16);
30733073
assert!(offset_of!(TSImportType, qualifier) == 20);
30743074
assert!(offset_of!(TSImportType, type_arguments) == 28);

crates/oxc_ast/src/generated/ast_builder.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10621,15 +10621,15 @@ impl<'a> AstBuilder<'a> {
1062110621
///
1062210622
/// ## Parameters
1062310623
/// * `span`: The [`Span`] covering this node
10624-
/// * `argument`
10624+
/// * `source`
1062510625
/// * `options`
1062610626
/// * `qualifier`
1062710627
/// * `type_arguments`
1062810628
#[inline]
1062910629
pub fn ts_type_import_type<T1, T2>(
1063010630
self,
1063110631
span: Span,
10632-
argument: TSType<'a>,
10632+
source: TSType<'a>,
1063310633
options: T1,
1063410634
qualifier: Option<TSImportTypeQualifier<'a>>,
1063510635
type_arguments: T2,
@@ -10640,7 +10640,7 @@ impl<'a> AstBuilder<'a> {
1064010640
{
1064110641
TSType::TSImportType(self.alloc_ts_import_type(
1064210642
span,
10643-
argument,
10643+
source,
1064410644
options,
1064510645
qualifier,
1064610646
type_arguments,
@@ -14016,15 +14016,15 @@ impl<'a> AstBuilder<'a> {
1401614016
///
1401714017
/// ## Parameters
1401814018
/// * `span`: The [`Span`] covering this node
14019-
/// * `argument`
14019+
/// * `source`
1402014020
/// * `options`
1402114021
/// * `qualifier`
1402214022
/// * `type_arguments`
1402314023
#[inline]
1402414024
pub fn ts_type_query_expr_name_import_type<T1, T2>(
1402514025
self,
1402614026
span: Span,
14027-
argument: TSType<'a>,
14027+
source: TSType<'a>,
1402814028
options: T1,
1402914029
qualifier: Option<TSImportTypeQualifier<'a>>,
1403014030
type_arguments: T2,
@@ -14035,7 +14035,7 @@ impl<'a> AstBuilder<'a> {
1403514035
{
1403614036
TSTypeQueryExprName::TSImportType(self.alloc_ts_import_type(
1403714037
span,
14038-
argument,
14038+
source,
1403914039
options,
1404014040
qualifier,
1404114041
type_arguments,
@@ -14049,15 +14049,15 @@ impl<'a> AstBuilder<'a> {
1404914049
///
1405014050
/// ## Parameters
1405114051
/// * `span`: The [`Span`] covering this node
14052-
/// * `argument`
14052+
/// * `source`
1405314053
/// * `options`
1405414054
/// * `qualifier`
1405514055
/// * `type_arguments`
1405614056
#[inline]
1405714057
pub fn ts_import_type<T1, T2>(
1405814058
self,
1405914059
span: Span,
14060-
argument: TSType<'a>,
14060+
source: TSType<'a>,
1406114061
options: T1,
1406214062
qualifier: Option<TSImportTypeQualifier<'a>>,
1406314063
type_arguments: T2,
@@ -14068,7 +14068,7 @@ impl<'a> AstBuilder<'a> {
1406814068
{
1406914069
TSImportType {
1407014070
span,
14071-
argument,
14071+
source,
1407214072
options: options.into_in(self.allocator),
1407314073
qualifier,
1407414074
type_arguments: type_arguments.into_in(self.allocator),
@@ -14082,15 +14082,15 @@ impl<'a> AstBuilder<'a> {
1408214082
///
1408314083
/// ## Parameters
1408414084
/// * `span`: The [`Span`] covering this node
14085-
/// * `argument`
14085+
/// * `source`
1408614086
/// * `options`
1408714087
/// * `qualifier`
1408814088
/// * `type_arguments`
1408914089
#[inline]
1409014090
pub fn alloc_ts_import_type<T1, T2>(
1409114091
self,
1409214092
span: Span,
14093-
argument: TSType<'a>,
14093+
source: TSType<'a>,
1409414094
options: T1,
1409514095
qualifier: Option<TSImportTypeQualifier<'a>>,
1409614096
type_arguments: T2,
@@ -14100,7 +14100,7 @@ impl<'a> AstBuilder<'a> {
1410014100
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
1410114101
{
1410214102
Box::new_in(
14103-
self.ts_import_type(span, argument, options, qualifier, type_arguments),
14103+
self.ts_import_type(span, source, options, qualifier, type_arguments),
1410414104
self.allocator,
1410514105
)
1410614106
}

crates/oxc_ast/src/generated/derive_clone_in.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7468,7 +7468,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for TSImportType<'_> {
74687468
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
74697469
TSImportType {
74707470
span: CloneIn::clone_in(&self.span, allocator),
7471-
argument: CloneIn::clone_in(&self.argument, allocator),
7471+
source: CloneIn::clone_in(&self.source, allocator),
74727472
options: CloneIn::clone_in(&self.options, allocator),
74737473
qualifier: CloneIn::clone_in(&self.qualifier, allocator),
74747474
type_arguments: CloneIn::clone_in(&self.type_arguments, allocator),
@@ -7478,7 +7478,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for TSImportType<'_> {
74787478
fn clone_in_with_semantic_ids(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
74797479
TSImportType {
74807480
span: CloneIn::clone_in_with_semantic_ids(&self.span, allocator),
7481-
argument: CloneIn::clone_in_with_semantic_ids(&self.argument, allocator),
7481+
source: CloneIn::clone_in_with_semantic_ids(&self.source, allocator),
74827482
options: CloneIn::clone_in_with_semantic_ids(&self.options, allocator),
74837483
qualifier: CloneIn::clone_in_with_semantic_ids(&self.qualifier, allocator),
74847484
type_arguments: CloneIn::clone_in_with_semantic_ids(&self.type_arguments, allocator),

crates/oxc_ast/src/generated/derive_content_eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ impl ContentEq for TSTypeQueryExprName<'_> {
23292329

23302330
impl ContentEq for TSImportType<'_> {
23312331
fn content_eq(&self, other: &Self) -> bool {
2332-
ContentEq::content_eq(&self.argument, &other.argument)
2332+
ContentEq::content_eq(&self.source, &other.source)
23332333
&& ContentEq::content_eq(&self.options, &other.options)
23342334
&& ContentEq::content_eq(&self.qualifier, &other.qualifier)
23352335
&& ContentEq::content_eq(&self.type_arguments, &other.type_arguments)

crates/oxc_ast/src/generated/derive_dummy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2642,7 +2642,7 @@ impl<'a> Dummy<'a> for TSImportType<'a> {
26422642
fn dummy(allocator: &'a Allocator) -> Self {
26432643
Self {
26442644
span: Dummy::dummy(allocator),
2645-
argument: Dummy::dummy(allocator),
2645+
source: Dummy::dummy(allocator),
26462646
options: Dummy::dummy(allocator),
26472647
qualifier: Dummy::dummy(allocator),
26482648
type_arguments: Dummy::dummy(allocator),

crates/oxc_ast/src/serialize/ts.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,12 @@ impl ESTree for TSFunctionTypeParams<'_, '_> {
505505

506506
/// Serializer for `source` field of `TSImportType`.
507507
///
508-
/// * Field is named `argument` in Oxc AST.
509-
/// * Serialized as a `StringLiteral` - all other values are illegal syntax.
508+
/// Serialized as a `StringLiteral` - all other values are illegal syntax.
510509
#[ast_meta]
511510
#[estree(
512511
ts_type = "StringLiteral",
513512
raw_deser = "
514-
let source = DESER[TSType](POS_OFFSET.argument);
513+
let source = DESER[TSType](POS_OFFSET.source);
515514
if (source.type === 'TSLiteralType') {
516515
source = source.literal;
517516
if (PARENT) source.parent = parent;
@@ -525,7 +524,7 @@ pub struct TSImportTypeSource<'a, 'b>(pub &'b TSImportType<'a>);
525524

526525
impl ESTree for TSImportTypeSource<'_, '_> {
527526
fn serialize<S: Serializer>(&self, serializer: S) {
528-
let source = &self.0.argument;
527+
let source = &self.0.source;
529528
if let TSType::TSLiteralType(ts_lit_type) = source
530529
&& let TSLiteral::StringLiteral(str_lit) = &ts_lit_type.literal
531530
{

crates/oxc_ast_visit/src/generated/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3955,7 +3955,7 @@ pub mod walk {
39553955
let kind = AstKind::TSImportType(visitor.alloc(it));
39563956
visitor.enter_node(kind);
39573957
visitor.visit_span(&it.span);
3958-
visitor.visit_ts_type(&it.argument);
3958+
visitor.visit_ts_type(&it.source);
39593959
if let Some(options) = &it.options {
39603960
visitor.visit_object_expression(options);
39613961
}

crates/oxc_ast_visit/src/generated/visit_mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4164,7 +4164,7 @@ pub mod walk_mut {
41644164
let kind = AstType::TSImportType;
41654165
visitor.enter_node(kind);
41664166
visitor.visit_span(&mut it.span);
4167-
visitor.visit_ts_type(&mut it.argument);
4167+
visitor.visit_ts_type(&mut it.source);
41684168
if let Some(options) = &mut it.options {
41694169
visitor.visit_object_expression(options);
41704170
}

crates/oxc_codegen/src/gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,7 @@ impl Gen for TSTypeQueryExprName<'_> {
35153515
impl Gen for TSImportType<'_> {
35163516
fn r#gen(&self, p: &mut Codegen, ctx: Context) {
35173517
p.print_str("import(");
3518-
self.argument.print(p, ctx);
3518+
self.source.print(p, ctx);
35193519
if let Some(options) = &self.options {
35203520
p.print_str(", ");
35213521
options.print_expr(p, Precedence::Lowest, ctx);

0 commit comments

Comments
 (0)