Skip to content

Commit 39c042c

Browse files
committed
chore(transformer): enable class-properties plugin
1 parent b2bfacf commit 39c042c

File tree

5 files changed

+12
-156
lines changed

5 files changed

+12
-156
lines changed

crates/oxc_transformer/src/es2022/class_properties/private.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
11711171
//
11721172
// TODO(improve-on-babel): Consider remove this logic, because it seems no runtime behavior change.
11731173
let result = self.transform_chain_element_recursively(callee, ctx)?;
1174-
let object = callee.to_member_expression_mut().object_mut();
1174+
let object = callee.as_member_expression_mut()?.object_mut();
11751175
let (assignment, context) = self.duplicate_object(ctx.ast.move_expression(object), ctx);
11761176
*object = assignment;
11771177
let callee = ctx.ast.move_expression(&mut call_expr.callee);

crates/oxc_transformer/src/options/env.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ impl EnvOptions {
8484
es2021: ES2021Options { logical_assignment_operators: true },
8585
es2022: ES2022Options {
8686
class_static_block: true,
87-
class_properties: if include_unfinished_plugins {
88-
Some(ClassPropertiesOptions::default())
89-
} else {
90-
None
91-
},
87+
class_properties: Some(ClassPropertiesOptions::default()),
9288
},
9389
}
9490
}
@@ -139,9 +135,7 @@ impl EnvOptions {
139135
}
140136
}
141137
engine_targets.insert(Engine::Es, es_target.unwrap_or(ESTarget::default()).version());
142-
let mut env_options = EnvOptions::from(engine_targets);
143-
env_options.es2022.class_properties = None;
144-
Ok(env_options)
138+
Ok(EnvOptions::from(engine_targets))
145139
}
146140
}
147141

crates/oxc_transformer/src/options/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ impl From<ESTarget> for TransformOptions {
122122
fn from(target: ESTarget) -> Self {
123123
let mut engine_targets = EngineTargets::default();
124124
engine_targets.insert(Engine::Es, target.version());
125-
let mut env = EnvOptions::from(engine_targets);
126-
env.es2022.class_properties = None;
125+
let env = EnvOptions::from(engine_targets);
127126
Self { env, ..Self::default() }
128127
}
129128
}
Lines changed: 4 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,8 @@
11
commit: 54a8389f
22

33
node: v22.12.0
4+
filter: fixtures/babel
5+
include: **/*.{test,spec}.?(c|m)[jt]s?(x)
6+
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*, ""
47

5-
Passed: 186 of 215 (86.51%)
6-
7-
Failures:
8-
9-
./fixtures/babel/babel-plugin-transform-arrow-functions-test-fixtures-arrow-functions-implicit-var-arguments-exec.test.js
10-
'eval' and 'arguments' cannot be used as a binding identifier in strict mode
11-
12-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-assumption-setPublicClassFields-static-infer-name-exec.test.js
13-
AssertionError: expected '_Class' to be 'Foo' // Object.is equality
14-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-assumption-setPublicClassFields-static-infer-name-exec.test.js:8:19
15-
16-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-assumption-setPublicClassFields-static-super-exec.test.js
17-
Invalid access to super
18-
19-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-nested-class-super-call-in-decorator-exec.test.js
20-
AssertionError: expected undefined to be 'hello' // Object.is equality
21-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-nested-class-super-call-in-decorator-exec.test.js:21:28
22-
23-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-nested-class-super-property-in-accessor-key-exec.test.js
24-
Unexpected token `[`. Expected * for generator, private key, identifier or async
25-
26-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-nested-class-super-property-in-decorator-exec.test.js
27-
AssertionError: expected undefined to be 'hello' // Object.is equality
28-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-nested-class-super-property-in-decorator-exec.test.js:22:28
29-
30-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-constructor-collision-exec.test.js
31-
AssertionError: expected undefined to be 'bar' // Object.is equality
32-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-constructor-collision-exec.test.js:18:19
33-
34-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-constructor-collision-exec.test.js
35-
AssertionError: expected undefined to be 'bar' // Object.is equality
36-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-constructor-collision-exec.test.js:21:19
37-
38-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-nested-class-computed-redeclared-exec.test.js
39-
Private field '#foo' must be declared in an enclosing class
40-
41-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-nested-class-extends-computed-exec.test.js
42-
AssertionError: expected [Function] to not throw an error but 'TypeError: attempted to use private f…' was thrown
43-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:1438:21)
44-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:923:17)
45-
at Proxy.methodWrapper (./node_modules/.pnpm/chai@5.1.2/node_modules/chai/chai.js:1610:25)
46-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-nested-class-extends-computed-exec.test.js:36:9
47-
48-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-in-function-param-with-transform-exec.test.js
49-
TypeError: Cannot convert undefined or null to object
50-
at hasOwnProperty (<anonymous>)
51-
at _classPrivateFieldBase (./node_modules/.pnpm/@babel+runtime@7.26.0/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js:2:26)
52-
at value (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-in-function-param-with-transform-exec.test.js:63:11)
53-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-in-function-param-with-transform-exec.test.js:44:198
54-
at j (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-in-function-param-with-transform-exec.test.js:45:6)
55-
at Function.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-in-function-param-with-transform-exec.test.js:52:11)
56-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-in-function-param-with-transform-exec.test.js:71:6
57-
58-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-member-optional-call-with-transform-exec.test.js
59-
TypeError: Cannot convert undefined or null to object
60-
at hasOwnProperty (<anonymous>)
61-
at _classPrivateFieldBase (./node_modules/.pnpm/@babel+runtime@7.26.0/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js:2:26)
62-
at value (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-member-optional-call-with-transform-exec.test.js:123:11)
63-
at Function.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-member-optional-call-with-transform-exec.test.js:24:134)
64-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-optional-chain-member-optional-call-with-transform-exec.test.js:131:6
65-
66-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-parenthesized-optional-member-call-exec.test.js
67-
TypeError: Cannot read properties of undefined (reading 'bind')
68-
at Foo.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-parenthesized-optional-member-call-exec.test.js:20:59)
69-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-parenthesized-optional-member-call-exec.test.js:78:12
70-
71-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-parenthesized-optional-member-call-with-transform-exec.test.js
72-
TypeError: Cannot read properties of undefined (reading 'bind')
73-
at Foo.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-parenthesized-optional-member-call-with-transform-exec.test.js:20:59)
74-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-loose-parenthesized-optional-member-call-with-transform-exec.test.js:78:12
75-
76-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-nested-class-computed-redeclared-exec.test.js
77-
Private field '#foo' must be declared in an enclosing class
78-
79-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-nested-class-extends-computed-exec.test.js
80-
AssertionError: expected [Function] to not throw an error but 'TypeError: Private element is not pre…' was thrown
81-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:1438:21)
82-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:923:17)
83-
at Proxy.methodWrapper (./node_modules/.pnpm/chai@5.1.2/node_modules/chai/chai.js:1610:25)
84-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-nested-class-extends-computed-exec.test.js:31:9
85-
86-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-static-shadow-exec.test.js
87-
TypeError: e.has is not a function
88-
at _assertClassBrand (./node_modules/.pnpm/@babel+runtime@7.26.0/node_modules/@babel/runtime/helpers/assertClassBrand.js:2:44)
89-
at func (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-static-shadow-exec.test.js:10:12)
90-
at Function.method (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-static-shadow-exec.test.js:12:11)
91-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-private-static-shadow-exec.test.js:16:14
92-
93-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-computed-toPrimitive-exec.test.js
94-
AssertionError: expected [Function] to throw error including '@@toPrimitive must return a primitive…' but got 'Cannot convert object to primitive va…'
95-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:1438:21)
96-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:923:17)
97-
at Proxy.methodWrapper (./node_modules/.pnpm/chai@5.1.2/node_modules/chai/chai.js:1610:25)
98-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-computed-toPrimitive-exec.test.js:37:5
99-
100-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-delete-super-property-exec.test.js
101-
Invalid access to super
102-
103-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-loose-static-infer-name-exec.test.js
104-
AssertionError: expected '_Class' to be 'Foo' // Object.is equality
105-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-loose-static-infer-name-exec.test.js:8:19
106-
107-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-loose-static-super-exec.test.js
108-
Invalid access to super
109-
110-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-static-infer-name-exec.test.js
111-
AssertionError: expected '_Class' to be 'Foo' // Object.is equality
112-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-static-infer-name-exec.test.js:9:19
113-
114-
./fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-static-super-exec.test.js
115-
Invalid access to super
116-
117-
./fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-assumption-noDocumentAll-parenthesized-expression-member-call-exec.test.js
118-
TypeError: Cannot read properties of undefined (reading 'x')
119-
at m (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-assumption-noDocumentAll-parenthesized-expression-member-call-exec.test.js:10:16)
120-
at Foo.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-assumption-noDocumentAll-parenthesized-expression-member-call-exec.test.js:25:63)
121-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-assumption-noDocumentAll-parenthesized-expression-member-call-exec.test.js:68:12
122-
123-
./fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-exec.test.js
124-
TypeError: Cannot read properties of undefined (reading 'x')
125-
at m (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-exec.test.js:10:16)
126-
at Foo.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-exec.test.js:25:63)
127-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-exec.test.js:68:12
128-
129-
./fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-loose-exec.test.js
130-
TypeError: Cannot read properties of undefined (reading 'x')
131-
at m (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-loose-exec.test.js:10:16)
132-
at Foo.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-loose-exec.test.js:25:63)
133-
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-loose-exec.test.js:68:12
134-
135-
./fixtures/babel/babel-preset-env-test-fixtures-plugins-integration-issue-15170-exec.test.js
136-
AssertionError: expected [Function] to not throw an error but 'ReferenceError: x is not defined' was thrown
137-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:1438:21)
138-
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:923:17)
139-
at Proxy.methodWrapper (./node_modules/.pnpm/chai@5.1.2/node_modules/chai/chai.js:1610:25)
140-
at ./tasks/transform_conformance/fixtures/babel/babel-preset-env-test-fixtures-plugins-integration-issue-15170-exec.test.js:6:9
141-
142-
./fixtures/babel/babel-preset-env-test-fixtures-sanity-check-es2015-constants-exec.test.js
143-
TypeError: Assignment to constant variable.
144-
at ./tasks/transform_conformance/fixtures/babel/babel-preset-env-test-fixtures-sanity-check-es2015-constants-exec.test.js:5:6
145-
146-
./fixtures/babel/babel-preset-env-test-fixtures-sanity-regex-dot-all-exec.test.js
147-
AssertionError: expected false to be true // Object.is equality
148-
at ./tasks/transform_conformance/fixtures/babel/babel-preset-env-test-fixtures-sanity-regex-dot-all-exec.test.js:10:37
8+
No test files found, exiting with code 1
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
commit: 54a8389f
22

33
node: v22.12.0
4+
filter: fixtures/oxc
5+
include: **/*.{test,spec}.?(c|m)[jt]s?(x)
6+
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*, ""
47

5-
Passed: 3 of 3 (100.00%)
8+
No test files found, exiting with code 1

0 commit comments

Comments
 (0)