diff --git a/.github/actions/clone-submodules/action.yml b/.github/actions/clone-submodules/action.yml index 2cc7397776090..e2e2f03460dd1 100644 --- a/.github/actions/clone-submodules/action.yml +++ b/.github/actions/clone-submodules/action.yml @@ -38,4 +38,4 @@ runs: show-progress: false repository: oxc-project/acorn-test262 path: tasks/coverage/acorn-test262 - ref: e6d4a8915d6825132e03b4e517b51f97a1536a3a # Latest main at 28/5/25 + ref: 359faaadce848c92efcf19dcaf7446740f8e27f4 # Latest main at 30/5/25 diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index e8725fab4cca3..43fe90379dce0 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1913,7 +1913,6 @@ pub struct Class<'a> { /// @Bar() // <-- Decorator /// class Foo {} /// ``` - #[ts] pub decorators: Vec<'a, Decorator<'a>>, /// Class identifier, AKA the name pub id: Option>, @@ -2045,7 +2044,6 @@ pub struct MethodDefinition<'a> { /// /// This will always be true when an `abstract` modifier is used on the method. pub r#type: MethodDefinitionType, - #[ts] pub decorators: Vec<'a, Decorator<'a>>, #[estree(via = MethodDefinitionKey)] pub key: PropertyKey<'a>, @@ -2085,7 +2083,6 @@ pub struct PropertyDefinition<'a> { /// Decorators applied to the property. /// /// See [`Decorator`] for more information. - #[ts] pub decorators: Vec<'a, Decorator<'a>>, /// The expression used to declare the property. pub key: PropertyKey<'a>, @@ -2308,7 +2305,6 @@ pub struct AccessorProperty<'a> { /// Decorators applied to the accessor property. /// /// See [`Decorator`] for more information. - #[ts] pub decorators: Vec<'a, Decorator<'a>>, /// The expression used to declare the property. pub key: PropertyKey<'a>, diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index 191a419479abc..7d62632ef4521 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -1455,7 +1455,7 @@ impl ESTree for Class<'_> { state.serialize_field("type", &self.r#type); state.serialize_field("start", &self.span.start); state.serialize_field("end", &self.span.end); - state.serialize_ts_field("decorators", &self.decorators); + state.serialize_field("decorators", &self.decorators); state.serialize_field("id", &self.id); state.serialize_ts_field("typeParameters", &self.type_parameters); state.serialize_field("superClass", &self.super_class); @@ -1506,7 +1506,7 @@ impl ESTree for MethodDefinition<'_> { state.serialize_field("type", &self.r#type); state.serialize_field("start", &self.span.start); state.serialize_field("end", &self.span.end); - state.serialize_ts_field("decorators", &self.decorators); + state.serialize_field("decorators", &self.decorators); state.serialize_field("key", &crate::serialize::js::MethodDefinitionKey(self)); state.serialize_field("value", &self.value); state.serialize_field("kind", &self.kind); @@ -1536,7 +1536,7 @@ impl ESTree for PropertyDefinition<'_> { state.serialize_field("type", &self.r#type); state.serialize_field("start", &self.span.start); state.serialize_field("end", &self.span.end); - state.serialize_ts_field("decorators", &self.decorators); + state.serialize_field("decorators", &self.decorators); state.serialize_field("key", &self.key); state.serialize_ts_field("typeAnnotation", &self.type_annotation); state.serialize_field("value", &self.value); @@ -1626,7 +1626,7 @@ impl ESTree for AccessorProperty<'_> { state.serialize_field("type", &self.r#type); state.serialize_field("start", &self.span.start); state.serialize_field("end", &self.span.end); - state.serialize_ts_field("decorators", &self.decorators); + state.serialize_field("decorators", &self.decorators); state.serialize_field("key", &self.key); state.serialize_ts_field("typeAnnotation", &self.type_annotation); state.serialize_field("value", &self.value); diff --git a/justfile b/justfile index f61656b39a31e..9a5cadaf7b004 100755 --- a/justfile +++ b/justfile @@ -40,7 +40,7 @@ submodules: just clone-submodule tasks/coverage/babel https://github.com/babel/babel.git 1d4546bcb80009303aab386b59f4df1fd335c1d5 just clone-submodule tasks/coverage/typescript https://github.com/microsoft/TypeScript.git 81c951894e93bdc37c6916f18adcd80de76679bc just clone-submodule tasks/prettier_conformance/prettier https://github.com/prettier/prettier.git 7584432401a47a26943dd7a9ca9a8e032ead7285 - just clone-submodule tasks/coverage/acorn-test262 https://github.com/oxc-project/acorn-test262 e6d4a8915d6825132e03b4e517b51f97a1536a3a + just clone-submodule tasks/coverage/acorn-test262 https://github.com/oxc-project/acorn-test262 359faaadce848c92efcf19dcaf7446740f8e27f4 just update-transformer-fixtures # Install git pre-commit to format files diff --git a/napi/parser/README.md b/napi/parser/README.md index 967c9c47ddb18..745312cead24b 100644 --- a/napi/parser/README.md +++ b/napi/parser/README.md @@ -18,6 +18,7 @@ If you need all ASTs in the same with-TS-properties format, use the `astType: 't The only differences between Oxc's AST and ESTree / TS-ESTree are: +- Support for Stage 3 [decorators](https://github.com/tc39/proposal-decorators). - Support for Stage 3 ECMA features [`import defer`](https://github.com/tc39/proposal-defer-import-eval) and [`import source`](https://github.com/tc39/proposal-source-phase-imports). - In TS-ESTree AST, `import.defer(...)` and `import.source(...)` are represented as an `ImportExpression` diff --git a/napi/parser/generated/deserialize/js.js b/napi/parser/generated/deserialize/js.js index f81bafca1e142..4363d90542315 100644 --- a/napi/parser/generated/deserialize/js.js +++ b/napi/parser/generated/deserialize/js.js @@ -833,6 +833,7 @@ function deserializeClass(pos) { type: deserializeClassType(pos + 132), start: deserializeU32(pos), end: deserializeU32(pos + 4), + decorators: deserializeVecDecorator(pos + 8), id: deserializeOptionBindingIdentifier(pos + 32), superClass: deserializeOptionExpression(pos + 72), body: deserializeBoxClassBody(pos + 120), @@ -853,6 +854,7 @@ function deserializeMethodDefinition(pos) { type: deserializeMethodDefinitionType(pos + 56), start: deserializeU32(pos), end: deserializeU32(pos + 4), + decorators: deserializeVecDecorator(pos + 8), key: deserializePropertyKey(pos + 32), value: deserializeBoxFunction(pos + 48), kind: deserializeMethodDefinitionKind(pos + 57), @@ -866,6 +868,7 @@ function deserializePropertyDefinition(pos) { type: deserializePropertyDefinitionType(pos + 72), start: deserializeU32(pos), end: deserializeU32(pos + 4), + decorators: deserializeVecDecorator(pos + 8), key: deserializePropertyKey(pos + 32), value: deserializeOptionExpression(pos + 56), computed: deserializeBool(pos + 73), @@ -896,6 +899,7 @@ function deserializeAccessorProperty(pos) { type: deserializeAccessorPropertyType(pos + 72), start: deserializeU32(pos), end: deserializeU32(pos + 4), + decorators: deserializeVecDecorator(pos + 8), key: deserializePropertyKey(pos + 32), value: deserializeOptionExpression(pos + 56), computed: deserializeBool(pos + 73), diff --git a/npm/oxc-types/types.d.ts b/npm/oxc-types/types.d.ts index 0a7f2a3e369b5..6dd5bbf00170b 100644 --- a/npm/oxc-types/types.d.ts +++ b/npm/oxc-types/types.d.ts @@ -647,7 +647,7 @@ export interface YieldExpression extends Span { export interface Class extends Span { type: ClassType; - decorators?: Array; + decorators: Array; id: BindingIdentifier | null; typeParameters?: TSTypeParameterDeclaration | null; superClass: Expression | null; @@ -669,7 +669,7 @@ export type ClassElement = StaticBlock | MethodDefinition | PropertyDefinition | export interface MethodDefinition extends Span { type: MethodDefinitionType; - decorators?: Array; + decorators: Array; key: PropertyKey; value: Function; kind: MethodDefinitionKind; @@ -684,7 +684,7 @@ export type MethodDefinitionType = 'MethodDefinition' | 'TSAbstractMethodDefinit export interface PropertyDefinition extends Span { type: PropertyDefinitionType; - decorators?: Array; + decorators: Array; key: PropertyKey; typeAnnotation?: TSTypeAnnotation | null; value: Expression | null; @@ -724,7 +724,7 @@ export type AccessorPropertyType = 'AccessorProperty' | 'TSAbstractAccessorPrope export interface AccessorProperty extends Span { type: AccessorPropertyType; - decorators?: Array; + decorators: Array; key: PropertyKey; typeAnnotation?: TSTypeAnnotation | null; value: Expression | null; diff --git a/tasks/coverage/snapshots/estree_acorn_jsx.snap b/tasks/coverage/snapshots/estree_acorn_jsx.snap index 8bdb209e3b272..689be88bc1e92 100644 --- a/tasks/coverage/snapshots/estree_acorn_jsx.snap +++ b/tasks/coverage/snapshots/estree_acorn_jsx.snap @@ -1,4 +1,4 @@ -commit: e6d4a891 +commit: 359faaad estree_acorn_jsx Summary: AST Parsed : 39/39 (100.00%) diff --git a/tasks/coverage/snapshots/estree_test262.snap b/tasks/coverage/snapshots/estree_test262.snap index 9bde56b6ee841..2d84ab3361a6a 100644 --- a/tasks/coverage/snapshots/estree_test262.snap +++ b/tasks/coverage/snapshots/estree_test262.snap @@ -1,8 +1,8 @@ commit: 4b5d36ab estree_test262 Summary: -AST Parsed : 44179/44179 (100.00%) -Positive Passed: 44170/44179 (99.98%) +AST Parsed : 44201/44201 (100.00%) +Positive Passed: 44192/44201 (99.98%) Mismatch: tasks/coverage/test262/test/language/expressions/assignment/fn-name-lhs-cover.js Mismatch: tasks/coverage/test262/test/language/expressions/assignment/target-cover-id.js