diff --git a/crates/oxc_transformer/src/options/env.rs b/crates/oxc_transformer/src/options/env.rs index 8d1011897894a..eee0aa4586115 100644 --- a/crates/oxc_transformer/src/options/env.rs +++ b/crates/oxc_transformer/src/options/env.rs @@ -139,7 +139,9 @@ impl EnvOptions { } } engine_targets.insert(Engine::Es, es_target.unwrap_or(ESTarget::default()).version()); - Ok(EnvOptions::from(engine_targets)) + let mut env_options = EnvOptions::from(engine_targets); + env_options.es2022.class_properties = None; + Ok(env_options) } } diff --git a/crates/oxc_transformer/tests/integrations/es_target.rs b/crates/oxc_transformer/tests/integrations/es_target.rs index 53c07e631f381..29cf0d1aa5726 100644 --- a/crates/oxc_transformer/tests/integrations/es_target.rs +++ b/crates/oxc_transformer/tests/integrations/es_target.rs @@ -19,6 +19,7 @@ fn es_target() { ("es2020", "a ||= b"), ("es2019", "1n ** 2n"), // test target error ("es2021", "class foo { static {} }"), + ("es2021", "class Foo { #a; }"), // Plugin not ready ]; // Test no transformation for esnext. diff --git a/crates/oxc_transformer/tests/integrations/snapshots/es_target.snap b/crates/oxc_transformer/tests/integrations/snapshots/es_target.snap index 639b97e1269cd..29cc25b059a85 100644 --- a/crates/oxc_transformer/tests/integrations/snapshots/es_target.snap +++ b/crates/oxc_transformer/tests/integrations/snapshots/es_target.snap @@ -74,5 +74,13 @@ a || (a = b); ########## 9 es2021 class foo { static {} } ---------- -class foo {} -(() => {})(); +class foo { + static #_ = (() => {})(); +} + +########## 10 es2021 +class Foo { #a; } +---------- +class Foo { + #a; +} diff --git a/napi/transform/test/transform.test.ts b/napi/transform/test/transform.test.ts index e3505aa1de6e1..ae93af02b607e 100644 --- a/napi/transform/test/transform.test.ts +++ b/napi/transform/test/transform.test.ts @@ -75,6 +75,14 @@ describe('target', () => { assert(ret.code); assert.equal(ret.code, code); }); + + it('should turn off class propertiers because plugin is not ready', () => { + const code = 'class Foo {\n\t#a;\n}\n'; + const ret = transform('test.js', code, { target: 'es2015' }); + assert(ret.errors.length == 0); + assert(ret.code); + assert.equal(ret.code, code); + }); }); describe('modules', () => {