Skip to content
Draft
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
17 changes: 6 additions & 11 deletions apps/oxlint/src-js/generated/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5278,23 +5278,18 @@ function deserializeTSMappedType(pos) {
nameType: null,
typeAnnotation: null,
optional: null,
readonly: deserializeOptionTSMappedTypeModifierOperator(pos + 53),
readonly: deserializeOptionTSMappedTypeModifierOperator(pos + 93),
start,
end,
range: [start, end],
parent,
}),
typeParameter = deserializeBoxTSTypeParameter(pos + 8),
key = typeParameter.name;
key.parent = parent;
let { constraint } = typeParameter;
constraint !== null && (constraint.parent = parent);
let optional = deserializeOptionTSMappedTypeModifierOperator(pos + 52);
optional = deserializeOptionTSMappedTypeModifierOperator(pos + 92);
optional === null && (optional = false);
node.key = key;
node.constraint = constraint;
node.nameType = deserializeOptionTSType(pos + 16);
node.typeAnnotation = deserializeOptionTSType(pos + 32);
node.key = deserializeBindingIdentifier(pos + 8);
node.constraint = deserializeTSType(pos + 40);
node.nameType = deserializeOptionTSType(pos + 56);
node.typeAnnotation = deserializeOptionTSType(pos + 72);
node.optional = optional;
parent = previousParent;
return node;
Expand Down
4 changes: 2 additions & 2 deletions apps/oxlint/src-js/generated/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1546,8 +1546,8 @@ export interface TSConstructorType extends Span {

export interface TSMappedType extends Span {
type: 'TSMappedType';
key: TSTypeParameter['name'];
constraint: TSTypeParameter['constraint'];
key: BindingIdentifier;
constraint: TSType;
nameType: TSType | null;
typeAnnotation: TSType | null;
optional: TSMappedTypeModifierOperator | false;
Expand Down
11 changes: 4 additions & 7 deletions crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,15 +1483,12 @@ pub struct TSConstructorType<'a> {
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(
add_fields(key = TSMappedTypeKey, constraint = TSMappedTypeConstraint),
field_order(key, constraint, name_type, type_annotation, optional, readonly, span),
)]
pub struct TSMappedType<'a> {
pub span: Span,
/// Key type parameter, e.g. `P` in `[P in keyof T]`.
#[estree(skip)]
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
/// The type parameter name (e.g., `P` in `[P in keyof T]`)
pub key: BindingIdentifier<'a>,
/// The constraint (e.g., `keyof T` in `[P in keyof T]`)
pub constraint: TSType<'a>,
pub name_type: Option<TSType<'a>>,
pub type_annotation: Option<TSType<'a>>,
/// Optional modifier on type annotation
Expand Down
30 changes: 16 additions & 14 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,15 +1479,16 @@ const _: () = {
assert!(offset_of!(TSConstructorType, scope_id) == 32);

// Padding: 2 bytes
assert!(size_of::<TSMappedType>() == 56);
assert!(size_of::<TSMappedType>() == 96);
assert!(align_of::<TSMappedType>() == 8);
assert!(offset_of!(TSMappedType, span) == 0);
assert!(offset_of!(TSMappedType, type_parameter) == 8);
assert!(offset_of!(TSMappedType, name_type) == 16);
assert!(offset_of!(TSMappedType, type_annotation) == 32);
assert!(offset_of!(TSMappedType, optional) == 52);
assert!(offset_of!(TSMappedType, readonly) == 53);
assert!(offset_of!(TSMappedType, scope_id) == 48);
assert!(offset_of!(TSMappedType, key) == 8);
assert!(offset_of!(TSMappedType, constraint) == 40);
assert!(offset_of!(TSMappedType, name_type) == 56);
assert!(offset_of!(TSMappedType, type_annotation) == 72);
assert!(offset_of!(TSMappedType, optional) == 92);
assert!(offset_of!(TSMappedType, readonly) == 93);
assert!(offset_of!(TSMappedType, scope_id) == 88);

assert!(size_of::<TSMappedTypeModifierOperator>() == 1);
assert!(align_of::<TSMappedTypeModifierOperator>() == 1);
Expand Down Expand Up @@ -3086,15 +3087,16 @@ const _: () = if cfg!(target_family = "wasm") || align_of::<u64>() == 8 {
assert!(offset_of!(TSConstructorType, scope_id) == 20);

// Padding: 2 bytes
assert!(size_of::<TSMappedType>() == 36);
assert!(size_of::<TSMappedType>() == 60);
assert!(align_of::<TSMappedType>() == 4);
assert!(offset_of!(TSMappedType, span) == 0);
assert!(offset_of!(TSMappedType, type_parameter) == 8);
assert!(offset_of!(TSMappedType, name_type) == 12);
assert!(offset_of!(TSMappedType, type_annotation) == 20);
assert!(offset_of!(TSMappedType, optional) == 32);
assert!(offset_of!(TSMappedType, readonly) == 33);
assert!(offset_of!(TSMappedType, scope_id) == 28);
assert!(offset_of!(TSMappedType, key) == 8);
assert!(offset_of!(TSMappedType, constraint) == 28);
assert!(offset_of!(TSMappedType, name_type) == 36);
assert!(offset_of!(TSMappedType, type_annotation) == 44);
assert!(offset_of!(TSMappedType, optional) == 56);
assert!(offset_of!(TSMappedType, readonly) == 57);
assert!(offset_of!(TSMappedType, scope_id) == 52);

assert!(size_of::<TSMappedTypeModifierOperator>() == 1);
assert!(align_of::<TSMappedTypeModifierOperator>() == 1);
Expand Down
96 changes: 48 additions & 48 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10661,27 +10661,27 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`.
/// * `key`: The type parameter name (e.g., `P` in `[P in keyof T]`)
/// * `constraint`: The constraint (e.g., `keyof T` in `[P in keyof T]`)
/// * `name_type`
/// * `type_annotation`
/// * `optional`: Optional modifier on type annotation
/// * `readonly`: Readonly modifier before keyed index signature
#[inline]
pub fn ts_type_mapped_type<T1>(
pub fn ts_type_mapped_type(
self,
span: Span,
type_parameter: T1,
key: BindingIdentifier<'a>,
constraint: TSType<'a>,
name_type: Option<TSType<'a>>,
type_annotation: Option<TSType<'a>>,
optional: Option<TSMappedTypeModifierOperator>,
readonly: Option<TSMappedTypeModifierOperator>,
) -> TSType<'a>
where
T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>,
{
) -> TSType<'a> {
TSType::TSMappedType(self.alloc_ts_mapped_type(
span,
type_parameter,
key,
constraint,
name_type,
type_annotation,
optional,
Expand All @@ -10695,29 +10695,29 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`.
/// * `key`: The type parameter name (e.g., `P` in `[P in keyof T]`)
/// * `constraint`: The constraint (e.g., `keyof T` in `[P in keyof T]`)
/// * `name_type`
/// * `type_annotation`
/// * `optional`: Optional modifier on type annotation
/// * `readonly`: Readonly modifier before keyed index signature
/// * `scope_id`
#[inline]
pub fn ts_type_mapped_type_with_scope_id<T1>(
pub fn ts_type_mapped_type_with_scope_id(
self,
span: Span,
type_parameter: T1,
key: BindingIdentifier<'a>,
constraint: TSType<'a>,
name_type: Option<TSType<'a>>,
type_annotation: Option<TSType<'a>>,
optional: Option<TSMappedTypeModifierOperator>,
readonly: Option<TSMappedTypeModifierOperator>,
scope_id: ScopeId,
) -> TSType<'a>
where
T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>,
{
) -> TSType<'a> {
TSType::TSMappedType(self.alloc_ts_mapped_type_with_scope_id(
span,
type_parameter,
key,
constraint,
name_type,
type_annotation,
optional,
Expand Down Expand Up @@ -14329,27 +14329,27 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`.
/// * `key`: The type parameter name (e.g., `P` in `[P in keyof T]`)
/// * `constraint`: The constraint (e.g., `keyof T` in `[P in keyof T]`)
/// * `name_type`
/// * `type_annotation`
/// * `optional`: Optional modifier on type annotation
/// * `readonly`: Readonly modifier before keyed index signature
#[inline]
pub fn ts_mapped_type<T1>(
pub fn ts_mapped_type(
self,
span: Span,
type_parameter: T1,
key: BindingIdentifier<'a>,
constraint: TSType<'a>,
name_type: Option<TSType<'a>>,
type_annotation: Option<TSType<'a>>,
optional: Option<TSMappedTypeModifierOperator>,
readonly: Option<TSMappedTypeModifierOperator>,
) -> TSMappedType<'a>
where
T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>,
{
) -> TSMappedType<'a> {
TSMappedType {
span,
type_parameter: type_parameter.into_in(self.allocator),
key,
constraint,
name_type,
type_annotation,
optional,
Expand All @@ -14365,28 +14365,28 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`.
/// * `key`: The type parameter name (e.g., `P` in `[P in keyof T]`)
/// * `constraint`: The constraint (e.g., `keyof T` in `[P in keyof T]`)
/// * `name_type`
/// * `type_annotation`
/// * `optional`: Optional modifier on type annotation
/// * `readonly`: Readonly modifier before keyed index signature
#[inline]
pub fn alloc_ts_mapped_type<T1>(
pub fn alloc_ts_mapped_type(
self,
span: Span,
type_parameter: T1,
key: BindingIdentifier<'a>,
constraint: TSType<'a>,
name_type: Option<TSType<'a>>,
type_annotation: Option<TSType<'a>>,
optional: Option<TSMappedTypeModifierOperator>,
readonly: Option<TSMappedTypeModifierOperator>,
) -> Box<'a, TSMappedType<'a>>
where
T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>,
{
) -> Box<'a, TSMappedType<'a>> {
Box::new_in(
self.ts_mapped_type(
span,
type_parameter,
key,
constraint,
name_type,
type_annotation,
optional,
Expand All @@ -14403,29 +14403,29 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`.
/// * `key`: The type parameter name (e.g., `P` in `[P in keyof T]`)
/// * `constraint`: The constraint (e.g., `keyof T` in `[P in keyof T]`)
/// * `name_type`
/// * `type_annotation`
/// * `optional`: Optional modifier on type annotation
/// * `readonly`: Readonly modifier before keyed index signature
/// * `scope_id`
#[inline]
pub fn ts_mapped_type_with_scope_id<T1>(
pub fn ts_mapped_type_with_scope_id(
self,
span: Span,
type_parameter: T1,
key: BindingIdentifier<'a>,
constraint: TSType<'a>,
name_type: Option<TSType<'a>>,
type_annotation: Option<TSType<'a>>,
optional: Option<TSMappedTypeModifierOperator>,
readonly: Option<TSMappedTypeModifierOperator>,
scope_id: ScopeId,
) -> TSMappedType<'a>
where
T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>,
{
) -> TSMappedType<'a> {
TSMappedType {
span,
type_parameter: type_parameter.into_in(self.allocator),
key,
constraint,
name_type,
type_annotation,
optional,
Expand All @@ -14441,30 +14441,30 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`.
/// * `key`: The type parameter name (e.g., `P` in `[P in keyof T]`)
/// * `constraint`: The constraint (e.g., `keyof T` in `[P in keyof T]`)
/// * `name_type`
/// * `type_annotation`
/// * `optional`: Optional modifier on type annotation
/// * `readonly`: Readonly modifier before keyed index signature
/// * `scope_id`
#[inline]
pub fn alloc_ts_mapped_type_with_scope_id<T1>(
pub fn alloc_ts_mapped_type_with_scope_id(
self,
span: Span,
type_parameter: T1,
key: BindingIdentifier<'a>,
constraint: TSType<'a>,
name_type: Option<TSType<'a>>,
type_annotation: Option<TSType<'a>>,
optional: Option<TSMappedTypeModifierOperator>,
readonly: Option<TSMappedTypeModifierOperator>,
scope_id: ScopeId,
) -> Box<'a, TSMappedType<'a>>
where
T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>,
{
) -> Box<'a, TSMappedType<'a>> {
Box::new_in(
self.ts_mapped_type_with_scope_id(
span,
type_parameter,
key,
constraint,
name_type,
type_annotation,
optional,
Expand Down
6 changes: 4 additions & 2 deletions crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,8 @@ impl<'new_alloc> CloneIn<'new_alloc> for TSMappedType<'_> {
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
TSMappedType {
span: CloneIn::clone_in(&self.span, allocator),
type_parameter: CloneIn::clone_in(&self.type_parameter, allocator),
key: CloneIn::clone_in(&self.key, allocator),
constraint: CloneIn::clone_in(&self.constraint, allocator),
name_type: CloneIn::clone_in(&self.name_type, allocator),
type_annotation: CloneIn::clone_in(&self.type_annotation, allocator),
optional: CloneIn::clone_in(&self.optional, allocator),
Expand All @@ -7566,7 +7567,8 @@ impl<'new_alloc> CloneIn<'new_alloc> for TSMappedType<'_> {
fn clone_in_with_semantic_ids(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
TSMappedType {
span: CloneIn::clone_in_with_semantic_ids(&self.span, allocator),
type_parameter: CloneIn::clone_in_with_semantic_ids(&self.type_parameter, allocator),
key: CloneIn::clone_in_with_semantic_ids(&self.key, allocator),
constraint: CloneIn::clone_in_with_semantic_ids(&self.constraint, allocator),
name_type: CloneIn::clone_in_with_semantic_ids(&self.name_type, allocator),
type_annotation: CloneIn::clone_in_with_semantic_ids(&self.type_annotation, allocator),
optional: CloneIn::clone_in_with_semantic_ids(&self.optional, allocator),
Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2364,7 +2364,8 @@ impl ContentEq for TSConstructorType<'_> {

impl ContentEq for TSMappedType<'_> {
fn content_eq(&self, other: &Self) -> bool {
ContentEq::content_eq(&self.type_parameter, &other.type_parameter)
ContentEq::content_eq(&self.key, &other.key)
&& ContentEq::content_eq(&self.constraint, &other.constraint)
&& ContentEq::content_eq(&self.name_type, &other.name_type)
&& ContentEq::content_eq(&self.type_annotation, &other.type_annotation)
&& ContentEq::content_eq(&self.optional, &other.optional)
Expand Down
5 changes: 3 additions & 2 deletions crates/oxc_ast/src/generated/derive_dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2692,11 +2692,12 @@ impl<'a> Dummy<'a> for TSConstructorType<'a> {
impl<'a> Dummy<'a> for TSMappedType<'a> {
/// Create a dummy [`TSMappedType`].
///
/// Has cost of making 1 allocation (80 bytes).
/// Has cost of making 1 allocation (8 bytes).
fn dummy(allocator: &'a Allocator) -> Self {
Self {
span: Dummy::dummy(allocator),
type_parameter: Dummy::dummy(allocator),
key: Dummy::dummy(allocator),
constraint: Dummy::dummy(allocator),
name_type: Dummy::dummy(allocator),
type_annotation: Dummy::dummy(allocator),
optional: Dummy::dummy(allocator),
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3025,8 +3025,8 @@ impl ESTree for TSMappedType<'_> {
fn serialize<S: Serializer>(&self, serializer: S) {
let mut state = serializer.serialize_struct();
state.serialize_field("type", &JsonSafeString("TSMappedType"));
state.serialize_field("key", &crate::serialize::ts::TSMappedTypeKey(self));
state.serialize_field("constraint", &crate::serialize::ts::TSMappedTypeConstraint(self));
state.serialize_field("key", &self.key);
state.serialize_field("constraint", &self.constraint);
state.serialize_field("nameType", &self.name_type);
state.serialize_field("typeAnnotation", &self.type_annotation);
state.serialize_field("optional", &crate::serialize::ts::TSMappedTypeOptional(self));
Expand Down
Loading