Skip to content

Commit

Permalink
chore(transformor): disable class properties transform (#7486)
Browse files Browse the repository at this point in the history
The plugin is not ready.
  • Loading branch information
Boshen committed Nov 26, 2024
1 parent 571d7e2 commit 713e210
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crates/oxc_transformer/src/options/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/oxc_transformer/tests/integrations/es_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions crates/oxc_transformer/tests/integrations/snapshots/es_target.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions napi/transform/test/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 713e210

Please sign in to comment.