Skip to content

Commit b9f80b9

Browse files
fix(ast/estree): Fix TSFunctionType and TSCallSignatureDeclaration (#9959)
Skips estree serialisation for the field named `this_param` for both `TSFunctionType` and `TSCallSignatureDeclaration` nodes. PR is part of ongoing work to align our AST's ESTree output with that of TS-ESLint's. Relates to #9705. --------- Co-authored-by: overlookmotel <[email protected]>
1 parent 0cdeedd commit b9f80b9

File tree

6 files changed

+3
-114
lines changed

6 files changed

+3
-114
lines changed

crates/oxc_ast/src/ast/ts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ pub struct TSIndexSignature<'a> {
975975
pub struct TSCallSignatureDeclaration<'a> {
976976
pub span: Span,
977977
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
978+
#[estree(skip)]
978979
pub this_param: Option<TSThisParameter<'a>>,
979980
pub params: Box<'a, FormalParameters<'a>>,
980981
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
@@ -1319,6 +1320,7 @@ pub struct TSFunctionType<'a> {
13191320
/// type T = (this: string, a: number) => void;
13201321
/// // ^^^^^^^^^^^^
13211322
/// ```
1323+
#[estree(skip)]
13221324
pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
13231325
/// Function parameters. Akin to [`Function::params`].
13241326
pub params: Box<'a, FormalParameters<'a>>,

crates/oxc_ast/src/generated/derive_estree.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,6 @@ impl ESTree for TSCallSignatureDeclaration<'_> {
29072907
state.serialize_field("start", &self.span.start);
29082908
state.serialize_field("end", &self.span.end);
29092909
state.serialize_field("typeParameters", &self.type_parameters);
2910-
state.serialize_field("thisParam", &self.this_param);
29112910
state.serialize_field("params", &self.params);
29122911
state.serialize_field("returnType", &self.return_type);
29132912
state.end();
@@ -3124,7 +3123,6 @@ impl ESTree for TSFunctionType<'_> {
31243123
state.serialize_field("start", &self.span.start);
31253124
state.serialize_field("end", &self.span.end);
31263125
state.serialize_field("typeParameters", &self.type_parameters);
3127-
state.serialize_field("thisParam", &self.this_param);
31283126
state.serialize_field("params", &self.params);
31293127
state.serialize_field("returnType", &self.return_type);
31303128
state.end();

napi/parser/deserialize-js.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,6 @@ function deserializeTSCallSignatureDeclaration(pos) {
16621662
start: deserializeU32(pos),
16631663
end: deserializeU32(pos + 4),
16641664
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
1665-
thisParam: deserializeOptionTSThisParameter(pos + 16),
16661665
params: deserializeBoxFormalParameters(pos + 48),
16671666
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
16681667
};
@@ -1798,7 +1797,6 @@ function deserializeTSFunctionType(pos) {
17981797
start: deserializeU32(pos),
17991798
end: deserializeU32(pos + 4),
18001799
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
1801-
thisParam: deserializeOptionBoxTSThisParameter(pos + 16),
18021800
params: deserializeBoxFormalParameters(pos + 24),
18031801
returnType: deserializeBoxTSTypeAnnotation(pos + 32),
18041802
};

napi/parser/deserialize-ts.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,6 @@ function deserializeTSCallSignatureDeclaration(pos) {
17271727
start: deserializeU32(pos),
17281728
end: deserializeU32(pos + 4),
17291729
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
1730-
thisParam: deserializeOptionTSThisParameter(pos + 16),
17311730
params: deserializeBoxFormalParameters(pos + 48),
17321731
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
17331732
};
@@ -1863,7 +1862,6 @@ function deserializeTSFunctionType(pos) {
18631862
start: deserializeU32(pos),
18641863
end: deserializeU32(pos + 4),
18651864
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
1866-
thisParam: deserializeOptionBoxTSThisParameter(pos + 16),
18671865
params: deserializeBoxFormalParameters(pos + 24),
18681866
returnType: deserializeBoxTSTypeAnnotation(pos + 32),
18691867
};

npm/oxc-types/types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ export interface TSIndexSignature extends Span {
12101210
export interface TSCallSignatureDeclaration extends Span {
12111211
type: 'TSCallSignatureDeclaration';
12121212
typeParameters: TSTypeParameterDeclaration | null;
1213-
thisParam: TSThisParameter | null;
12141213
params: ParamPattern[];
12151214
returnType: TSTypeAnnotation | null;
12161215
}
@@ -1307,7 +1306,6 @@ export interface TSImportType extends Span {
13071306
export interface TSFunctionType extends Span {
13081307
type: 'TSFunctionType';
13091308
typeParameters: TSTypeParameterDeclaration | null;
1310-
thisParam: TSThisParameter | null;
13111309
params: ParamPattern[];
13121310
returnType: TSTypeAnnotation;
13131311
}

0 commit comments

Comments
 (0)