Skip to content

Commit f3ddefb

Browse files
committed
fix(ast/estree): add missing fields to AssignmentTargetRest in TS-ESTree AST (#10456)
Part of #9705.
1 parent 21f3175 commit f3ddefb

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

crates/oxc_ast/src/ast/js.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,10 @@ pub struct ObjectAssignmentTarget<'a> {
896896
#[ast(visit)]
897897
#[derive(Debug)]
898898
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
899-
#[estree(rename = "RestElement")]
899+
#[estree(
900+
rename = "RestElement",
901+
add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull, value = TsNull),
902+
)]
900903
pub struct AssignmentTargetRest<'a> {
901904
pub span: Span,
902905
#[estree(rename = "argument")]

crates/oxc_ast/src/generated/derive_estree.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ impl ESTree for AssignmentTargetRest<'_> {
667667
state.serialize_field("start", &self.span.start);
668668
state.serialize_field("end", &self.span.end);
669669
state.serialize_field("argument", &self.target);
670+
state.serialize_ts_field("decorators", &crate::serialize::TsEmptyArray(self));
671+
state.serialize_ts_field("optional", &crate::serialize::TsFalse(self));
672+
state.serialize_ts_field("typeAnnotation", &crate::serialize::TsNull(self));
673+
state.serialize_ts_field("value", &crate::serialize::TsNull(self));
670674
state.end();
671675
}
672676
}

napi/parser/deserialize-ts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ function deserializeAssignmentTargetRest(pos) {
392392
start: deserializeU32(pos),
393393
end: deserializeU32(pos + 4),
394394
argument: deserializeAssignmentTarget(pos + 8),
395+
decorators: [],
396+
optional: false,
397+
typeAnnotation: null,
398+
value: null,
395399
};
396400
}
397401

npm/oxc-types/types.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ export interface ObjectAssignmentTarget extends Span {
274274
export interface AssignmentTargetRest extends Span {
275275
type: 'RestElement';
276276
argument: AssignmentTarget;
277+
decorators?: [];
278+
optional?: false;
279+
typeAnnotation?: null;
280+
value?: null;
277281
}
278282

279283
export type AssignmentTargetMaybeDefault = AssignmentTargetWithDefault | AssignmentTarget;

tasks/coverage/snapshots/estree_typescript.snap

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ commit: 15392346
22

33
estree_typescript Summary:
44
AST Parsed : 10619/10725 (99.01%)
5-
Positive Passed: 9013/10725 (84.04%)
5+
Positive Passed: 9036/10725 (84.25%)
66
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts
77
A class member cannot have the 'const' keyword.
88
Mismatch: tasks/coverage/typescript/tests/cases/compiler/accessOverriddenBaseClassMember1.ts
@@ -52,7 +52,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/assignmentCompatability
5252
Mismatch: tasks/coverage/typescript/tests/cases/compiler/assignmentCompatability42.ts
5353
Mismatch: tasks/coverage/typescript/tests/cases/compiler/assignmentCompatability8.ts
5454
Mismatch: tasks/coverage/typescript/tests/cases/compiler/assignmentCompatability9.ts
55-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts
5655
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/assignmentToInstantiationExpression.ts
5756
The left-hand side of an assignment expression must be a variable or a property access.
5857
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/assignmentToParenthesizedExpression1.ts
@@ -250,8 +249,6 @@ serde_json::from_str(oxc_json) error: number out of range at line 28 column 25
250249
251250
Mismatch: tasks/coverage/typescript/tests/cases/compiler/destructuringAssignmentWithDefault.ts
252251
Mismatch: tasks/coverage/typescript/tests/cases/compiler/destructuringAssignmentWithDefault2.ts
253-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/destructuringAssignmentWithStrictNullChecks.ts
254-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/destructuringTuple.ts
255252
Mismatch: tasks/coverage/typescript/tests/cases/compiler/destructuringUnspreadableIntoRest.ts
256253
Mismatch: tasks/coverage/typescript/tests/cases/compiler/doNotEmitDetachedComments.ts
257254
Mismatch: tasks/coverage/typescript/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts
@@ -738,7 +735,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/multivar.ts
738735
Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowTypeByInstanceof.ts
739736
Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowingOrderIndependent.ts
740737
Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowingUnionToUnion.ts
741-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/nestedObjectRest.ts
742738
Mismatch: tasks/coverage/typescript/tests/cases/compiler/newNamesInGlobalAugmentations1.ts
743739
Mismatch: tasks/coverage/typescript/tests/cases/compiler/noCrashOnThisTypeUsage.ts
744740
Mismatch: tasks/coverage/typescript/tests/cases/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile1.ts
@@ -897,13 +893,10 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationClas
897893
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationClasses.ts
898894
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDecorators.ts
899895
Unexpected token
900-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPattern2.ts
901896
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.ts
902897
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues2.ts
903-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringForOfArrayBindingPattern2.ts
904898
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.ts
905899
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.ts
906-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.ts
907900
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.ts
908901
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.ts
909902
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.ts
@@ -1091,7 +1084,6 @@ Unexpected token
10911084
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateNameInObjectLiteral-3.ts
10921085
Unexpected token
10931086
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateNameStaticFieldDestructuredBinding.ts
1094-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateWriteOnlyAccessorRead.ts
10951087
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/mixinClassesAnnotated.ts
10961088
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/mixinClassesAnonymous.ts
10971089
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationES2022.ts
@@ -1274,7 +1266,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/de
12741266
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/destructuringObjectAssignmentPatternWithNestedSpread.ts
12751267
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5.ts
12761268
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6.ts
1277-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment5.ts
12781269
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts
12791270
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5iterable.ts
12801271
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts
@@ -1301,14 +1292,7 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/es6/destructu
13011292
Missing initializer in destructuring declaration
13021293
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts
13031294
Missing initializer in destructuring declaration
1304-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/iterableArrayPattern24.ts
1305-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts
1306-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts
1307-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts
13081295
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts
1309-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/nonIterableRestElement1.ts
1310-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/nonIterableRestElement2.ts
1311-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/nonIterableRestElement3.ts
13121296
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/objectBindingPatternKeywordIdentifiers05.ts
13131297
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/objectBindingPatternKeywordIdentifiers06.ts
13141298
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts
@@ -1319,7 +1303,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/re
13191303
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern2.ts
13201304
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern3.ts
13211305
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern4.ts
1322-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/restElementWithAssignmentPattern5.ts
13231306
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/restElementWithInitializer1.ts
13241307
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/es6/destructuring/restElementWithInitializer2.ts
13251308
Cannot assign to this expression
@@ -1738,7 +1721,6 @@ A rest parameter must be last in a parameter list
17381721
Mismatch: tasks/coverage/typescript/tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts
17391722
Mismatch: tasks/coverage/typescript/tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts
17401723
Mismatch: tasks/coverage/typescript/tests/cases/conformance/functions/strictBindCallApply1.ts
1741-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/generators/generatorAssignability.ts
17421724
Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.ts
17431725
Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts
17441726
Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts
@@ -2326,7 +2308,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
23262308
'public' modifier cannot be used here.
23272309
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts
23282310
The left-hand side of a `for...of` statement may not be `async`
2329-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts
23302311
tasks/coverage/typescript/tests/cases/conformance/salsa/chainedPrototypeAssignment.ts
23312312
Unexpected estree file content error: 1 != 3
23322313
@@ -2462,9 +2443,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/types/objectT
24622443
A rest parameter must be last in a parameter list
24632444
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts
24642445
A rest parameter must be last in a parameter list
2465-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/rest/objectRest.ts
2466-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/rest/objectRestAssignment.ts
2467-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/rest/objectRestForOf.ts
24682446
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/types/rest/objectRestNegative.ts
24692447
A rest element must be last in a destructuring pattern
24702448
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/types/rest/objectRestPropertyMustBeLast.ts
@@ -2474,7 +2452,6 @@ A rest element must be last in a destructuring pattern
24742452
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/specifyingTypes/typeQueries/typeQueryOnClass.ts
24752453
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/specifyingTypes/typeQueries/typeofThis.ts
24762454
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/specifyingTypes/typeQueries/typeofThisWithImplicitThis.ts
2477-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/spread/objectSpreadNoTransform.ts
24782455
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf01.ts
24792456
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/stringLiteral/stringLiteralCheckedInIf02.ts
24802457
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/stringLiteral/stringLiteralMatchedInSwitch01.ts

0 commit comments

Comments
 (0)