Skip to content

Commit 4980b73

Browse files
fix(ast/estree): Add missing estree fields to TSIndexSignature and TSIndexSignatureName (#9968)
Add missing estree fields to TSIndexSignature and TSIndexSignatureName 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: Hiroshi Ogawa <[email protected]>
1 parent 71dce1f commit 4980b73

File tree

5 files changed

+12
-58
lines changed

5 files changed

+12
-58
lines changed

crates/oxc_ast/src/ast/ts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ pub enum TSSignature<'a> {
961961
#[ast(visit)]
962962
#[derive(Debug)]
963963
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
964+
#[estree(add_fields(accessibility = TsNull))]
964965
pub struct TSIndexSignature<'a> {
965966
pub span: Span,
966967
pub parameters: Vec<'a, TSIndexSignatureName<'a>>,
@@ -1034,7 +1035,7 @@ pub struct TSConstructSignatureDeclaration<'a> {
10341035
#[ast(visit)]
10351036
#[derive(Debug)]
10361037
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1037-
#[estree(rename = "Identifier")]
1038+
#[estree(rename = "Identifier", add_fields(decorators = TsEmptyArray, optional = TsFalse))]
10381039
pub struct TSIndexSignatureName<'a> {
10391040
pub span: Span,
10401041
#[estree(json_safe)]

crates/oxc_ast/src/generated/derive_estree.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,6 +2896,7 @@ impl ESTree for TSIndexSignature<'_> {
28962896
state.serialize_field("typeAnnotation", &self.type_annotation);
28972897
state.serialize_field("readonly", &self.readonly);
28982898
state.serialize_field("static", &self.r#static);
2899+
state.serialize_ts_field("accessibility", &crate::serialize::TsNull(self));
28992900
state.end();
29002901
}
29012902
}
@@ -2962,6 +2963,8 @@ impl ESTree for TSIndexSignatureName<'_> {
29622963
state.serialize_field("end", &self.span.end);
29632964
state.serialize_field("name", &JsonSafeString(self.name.as_str()));
29642965
state.serialize_field("typeAnnotation", &self.type_annotation);
2966+
state.serialize_ts_field("decorators", &crate::serialize::TsEmptyArray(self));
2967+
state.serialize_ts_field("optional", &crate::serialize::TsFalse(self));
29652968
state.end();
29662969
}
29672970
}

napi/parser/deserialize-ts.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ function deserializeTSIndexSignature(pos) {
17181718
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 40),
17191719
readonly: deserializeBool(pos + 48),
17201720
static: deserializeBool(pos + 49),
1721+
accessibility: null,
17211722
};
17221723
}
17231724

@@ -1766,6 +1767,8 @@ function deserializeTSIndexSignatureName(pos) {
17661767
end: deserializeU32(pos + 4),
17671768
name: deserializeStr(pos + 8),
17681769
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
1770+
decorators: [],
1771+
optional: false,
17691772
};
17701773
}
17711774

npm/oxc-types/types.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ export interface TSIndexSignature extends Span {
12051205
typeAnnotation: TSTypeAnnotation;
12061206
readonly: boolean;
12071207
static: boolean;
1208+
accessibility?: null;
12081209
}
12091210

12101211
export interface TSCallSignatureDeclaration extends Span {
@@ -1239,6 +1240,8 @@ export interface TSIndexSignatureName extends Span {
12391240
type: 'Identifier';
12401241
name: string;
12411242
typeAnnotation: TSTypeAnnotation;
1243+
decorators?: [];
1244+
optional?: false;
12421245
}
12431246

12441247
export interface TSInterfaceHeritage extends Span {

0 commit comments

Comments
 (0)