Skip to content

Commit

Permalink
fix(ast): type params field before params in TS function declaration …
Browse files Browse the repository at this point in the history
…types
  • Loading branch information
overlookmotel committed Oct 9, 2024
1 parent 994b60b commit f53ac44
Show file tree
Hide file tree
Showing 20 changed files with 576 additions and 576 deletions.
26 changes: 13 additions & 13 deletions crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,10 +1147,10 @@ pub struct TSIndexSignature<'a> {
pub struct TSCallSignatureDeclaration<'a> {
#[serde(flatten)]
pub span: Span,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub this_param: Option<TSThisParameter<'a>>,
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
}

#[ast]
Expand Down Expand Up @@ -1188,10 +1188,10 @@ pub struct TSMethodSignature<'a> {
pub computed: bool,
pub optional: bool,
pub kind: TSMethodSignatureKind,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
Expand All @@ -1207,9 +1207,9 @@ pub struct TSMethodSignature<'a> {
pub struct TSConstructSignatureDeclaration<'a> {
#[serde(flatten)]
pub span: Span,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
Expand Down Expand Up @@ -1562,28 +1562,28 @@ pub enum TSImportAttributeName<'a> {
pub struct TSFunctionType<'a> {
#[serde(flatten)]
pub span: Span,
/// Generic type parameters
///
/// ```ts
/// type T = <U>(x: U) => U;
/// // ^
/// ```
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
/// `this` parameter
///
/// ```ts
/// type T = (this: string, a: number) => void
/// type T = (this: string, a: number) => void;
/// // ^^^^^^^^^^^^
/// ```
pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
/// Function parameters. Akin to [`Function::params`].
pub params: Box<'a, FormalParameters<'a>>,
/// Return type of the function.
/// ```ts
/// type T = () => void
/// type T = () => void;
/// // ^^^^
/// ```
pub return_type: Box<'a, TSTypeAnnotation<'a>>,
/// Generic type parameters
///
/// ```ts
/// type T = <T>(x: T) => T
/// // ^
/// ```
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
}

#[ast(visit)]
Expand All @@ -1595,9 +1595,9 @@ pub struct TSConstructorType<'a> {
#[serde(flatten)]
pub span: Span,
pub r#abstract: bool,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Box<'a, TSTypeAnnotation<'a>>,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
}

/// TypeScript Mapped Type
Expand Down
72 changes: 36 additions & 36 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,10 @@ const _: () = {
assert!(size_of::<TSCallSignatureDeclaration>() == 64usize);
assert!(align_of::<TSCallSignatureDeclaration>() == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, span) == 0usize);
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 40usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 48usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 56usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 16usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 48usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 56usize);

assert!(size_of::<TSMethodSignatureKind>() == 1usize);
assert!(align_of::<TSMethodSignatureKind>() == 1usize);
Expand All @@ -1055,18 +1055,18 @@ const _: () = {
assert!(offset_of!(TSMethodSignature, computed) == 24usize);
assert!(offset_of!(TSMethodSignature, optional) == 25usize);
assert!(offset_of!(TSMethodSignature, kind) == 26usize);
assert!(offset_of!(TSMethodSignature, this_param) == 32usize);
assert!(offset_of!(TSMethodSignature, params) == 40usize);
assert!(offset_of!(TSMethodSignature, return_type) == 48usize);
assert!(offset_of!(TSMethodSignature, type_parameters) == 56usize);
assert!(offset_of!(TSMethodSignature, type_parameters) == 32usize);
assert!(offset_of!(TSMethodSignature, this_param) == 40usize);
assert!(offset_of!(TSMethodSignature, params) == 48usize);
assert!(offset_of!(TSMethodSignature, return_type) == 56usize);
assert!(offset_of!(TSMethodSignature, scope_id) == 64usize);

assert!(size_of::<TSConstructSignatureDeclaration>() == 40usize);
assert!(align_of::<TSConstructSignatureDeclaration>() == 8usize);
assert!(offset_of!(TSConstructSignatureDeclaration, span) == 0usize);
assert!(offset_of!(TSConstructSignatureDeclaration, params) == 8usize);
assert!(offset_of!(TSConstructSignatureDeclaration, return_type) == 16usize);
assert!(offset_of!(TSConstructSignatureDeclaration, type_parameters) == 24usize);
assert!(offset_of!(TSConstructSignatureDeclaration, type_parameters) == 8usize);
assert!(offset_of!(TSConstructSignatureDeclaration, params) == 16usize);
assert!(offset_of!(TSConstructSignatureDeclaration, return_type) == 24usize);
assert!(offset_of!(TSConstructSignatureDeclaration, scope_id) == 32usize);

assert!(size_of::<TSIndexSignatureName>() == 32usize);
Expand Down Expand Up @@ -1161,18 +1161,18 @@ const _: () = {
assert!(size_of::<TSFunctionType>() == 40usize);
assert!(align_of::<TSFunctionType>() == 8usize);
assert!(offset_of!(TSFunctionType, span) == 0usize);
assert!(offset_of!(TSFunctionType, this_param) == 8usize);
assert!(offset_of!(TSFunctionType, params) == 16usize);
assert!(offset_of!(TSFunctionType, return_type) == 24usize);
assert!(offset_of!(TSFunctionType, type_parameters) == 32usize);
assert!(offset_of!(TSFunctionType, type_parameters) == 8usize);
assert!(offset_of!(TSFunctionType, this_param) == 16usize);
assert!(offset_of!(TSFunctionType, params) == 24usize);
assert!(offset_of!(TSFunctionType, return_type) == 32usize);

assert!(size_of::<TSConstructorType>() == 40usize);
assert!(align_of::<TSConstructorType>() == 8usize);
assert!(offset_of!(TSConstructorType, span) == 0usize);
assert!(offset_of!(TSConstructorType, r#abstract) == 8usize);
assert!(offset_of!(TSConstructorType, params) == 16usize);
assert!(offset_of!(TSConstructorType, return_type) == 24usize);
assert!(offset_of!(TSConstructorType, type_parameters) == 32usize);
assert!(offset_of!(TSConstructorType, type_parameters) == 16usize);
assert!(offset_of!(TSConstructorType, params) == 24usize);
assert!(offset_of!(TSConstructorType, return_type) == 32usize);

assert!(size_of::<TSMappedType>() == 56usize);
assert!(align_of::<TSMappedType>() == 8usize);
Expand Down Expand Up @@ -2577,10 +2577,10 @@ const _: () = {
assert!(size_of::<TSCallSignatureDeclaration>() == 44usize);
assert!(align_of::<TSCallSignatureDeclaration>() == 4usize);
assert!(offset_of!(TSCallSignatureDeclaration, span) == 0usize);
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 32usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 36usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 40usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 12usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 36usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 40usize);

assert!(size_of::<TSMethodSignatureKind>() == 1usize);
assert!(align_of::<TSMethodSignatureKind>() == 1usize);
Expand All @@ -2592,18 +2592,18 @@ const _: () = {
assert!(offset_of!(TSMethodSignature, computed) == 16usize);
assert!(offset_of!(TSMethodSignature, optional) == 17usize);
assert!(offset_of!(TSMethodSignature, kind) == 18usize);
assert!(offset_of!(TSMethodSignature, this_param) == 20usize);
assert!(offset_of!(TSMethodSignature, params) == 24usize);
assert!(offset_of!(TSMethodSignature, return_type) == 28usize);
assert!(offset_of!(TSMethodSignature, type_parameters) == 32usize);
assert!(offset_of!(TSMethodSignature, type_parameters) == 20usize);
assert!(offset_of!(TSMethodSignature, this_param) == 24usize);
assert!(offset_of!(TSMethodSignature, params) == 28usize);
assert!(offset_of!(TSMethodSignature, return_type) == 32usize);
assert!(offset_of!(TSMethodSignature, scope_id) == 36usize);

assert!(size_of::<TSConstructSignatureDeclaration>() == 24usize);
assert!(align_of::<TSConstructSignatureDeclaration>() == 4usize);
assert!(offset_of!(TSConstructSignatureDeclaration, span) == 0usize);
assert!(offset_of!(TSConstructSignatureDeclaration, params) == 8usize);
assert!(offset_of!(TSConstructSignatureDeclaration, return_type) == 12usize);
assert!(offset_of!(TSConstructSignatureDeclaration, type_parameters) == 16usize);
assert!(offset_of!(TSConstructSignatureDeclaration, type_parameters) == 8usize);
assert!(offset_of!(TSConstructSignatureDeclaration, params) == 12usize);
assert!(offset_of!(TSConstructSignatureDeclaration, return_type) == 16usize);
assert!(offset_of!(TSConstructSignatureDeclaration, scope_id) == 20usize);

assert!(size_of::<TSIndexSignatureName>() == 20usize);
Expand Down Expand Up @@ -2698,18 +2698,18 @@ const _: () = {
assert!(size_of::<TSFunctionType>() == 24usize);
assert!(align_of::<TSFunctionType>() == 4usize);
assert!(offset_of!(TSFunctionType, span) == 0usize);
assert!(offset_of!(TSFunctionType, this_param) == 8usize);
assert!(offset_of!(TSFunctionType, params) == 12usize);
assert!(offset_of!(TSFunctionType, return_type) == 16usize);
assert!(offset_of!(TSFunctionType, type_parameters) == 20usize);
assert!(offset_of!(TSFunctionType, type_parameters) == 8usize);
assert!(offset_of!(TSFunctionType, this_param) == 12usize);
assert!(offset_of!(TSFunctionType, params) == 16usize);
assert!(offset_of!(TSFunctionType, return_type) == 20usize);

assert!(size_of::<TSConstructorType>() == 24usize);
assert!(align_of::<TSConstructorType>() == 4usize);
assert!(offset_of!(TSConstructorType, span) == 0usize);
assert!(offset_of!(TSConstructorType, r#abstract) == 8usize);
assert!(offset_of!(TSConstructorType, params) == 12usize);
assert!(offset_of!(TSConstructorType, return_type) == 16usize);
assert!(offset_of!(TSConstructorType, type_parameters) == 20usize);
assert!(offset_of!(TSConstructorType, type_parameters) == 12usize);
assert!(offset_of!(TSConstructorType, params) == 16usize);
assert!(offset_of!(TSConstructorType, return_type) == 20usize);

assert!(size_of::<TSMappedType>() == 36usize);
assert!(align_of::<TSMappedType>() == 4usize);
Expand Down
Loading

0 comments on commit f53ac44

Please sign in to comment.