Skip to content

Commit

Permalink
chore(transformer): enable class-properties plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing authored and overlookmotel committed Dec 20, 2024
1 parent c46793e commit 562abd5
Show file tree
Hide file tree
Showing 8 changed files with 2,985 additions and 2,696 deletions.
10 changes: 2 additions & 8 deletions crates/oxc_transformer/src/options/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ impl EnvOptions {
es2021: ES2021Options { logical_assignment_operators: true },
es2022: ES2022Options {
class_static_block: true,
class_properties: if include_unfinished_plugins {
Some(ClassPropertiesOptions::default())
} else {
None
},
class_properties: Some(ClassPropertiesOptions::default()),
},
}
}
Expand Down Expand Up @@ -139,9 +135,7 @@ impl EnvOptions {
}
}
engine_targets.insert(Engine::Es, es_target.unwrap_or(ESTarget::default()).version());
let mut env_options = EnvOptions::from(engine_targets);
env_options.es2022.class_properties = None;
Ok(env_options)
Ok(EnvOptions::from(engine_targets))
}
}

Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_transformer/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ impl From<ESTarget> for TransformOptions {
fn from(target: ESTarget) -> Self {
let mut engine_targets = EngineTargets::default();
engine_targets.insert(Engine::Es, target.version());
let mut env = EnvOptions::from(engine_targets);
env.es2022.class_properties = None;
let env = EnvOptions::from(engine_targets);
Self { env, ..Self::default() }
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/oxc_transformer/tests/integrations/es_target.rs
assertion_line: 50
snapshot_kind: text
---
########## 0 es5
Expand Down Expand Up @@ -80,13 +79,16 @@ a || (a = b);
########## 10 es2021
class foo { static {} }
----------
class foo {
static #_ = (() => {})();
}
class foo {}
(() => {})();

########## 11 es2021
class Foo { #a; }
----------
import _classPrivateFieldInitSpec from '@babel/runtime/helpers/classPrivateFieldInitSpec';
var _a = new WeakMap();
class Foo {
#a;
constructor() {
_classPrivateFieldInitSpec(this, _a, void 0);
}
}
65 changes: 38 additions & 27 deletions tasks/coverage/snapshots/semantic_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: 54a8389f

semantic_babel Summary:
AST Parsed : 2218/2218 (100.00%)
Positive Passed: 1849/2218 (83.36%)
Positive Passed: 1848/2218 (83.32%)
tasks/coverage/babel/packages/babel-parser/test/fixtures/annex-b/enabled/3.3-function-in-if-body/input.js
semantic error: Symbol scope ID mismatch for "f":
after transform: SymbolId(0): ScopeId(4294967294)
Expand Down Expand Up @@ -32,6 +32,17 @@ semantic error: Expected a semicolon or an implicit semicolon after a statement,
tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-properties/arguments-in-key/input.js
semantic error: 'arguments' is not allowed in class field initializer

tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-properties/await-identifier-in-computed-property-inside-params-of-function-inside-params-of-async-function/input.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["_asyncToGenerator", "_defineProperty"]
rebuilt : ScopeId(0): ["_asyncToGenerator", "_await", "_defineProperty"]
Bindings mismatch:
after transform: ScopeId(2): ["_await", "f", "x"]
rebuilt : ScopeId(2): ["f", "x"]
Symbol scope ID mismatch for "_await":
after transform: SymbolId(3): ScopeId(2)
rebuilt : SymbolId(2): ScopeId(0)

tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-properties/await-in-property-in-params-of-async-arrow/input.js
semantic error: Expected a semicolon or an implicit semicolon after a statement, but found none

Expand Down Expand Up @@ -80,8 +91,8 @@ rebuilt : ScopeId(1): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/class-private-property/typescript/input.js
semantic error: Unresolved references mismatch:
after transform: ["Array", "foo"]
rebuilt : ["foo"]
after transform: ["Array", "WeakMap", "foo", "require"]
rebuilt : ["WeakMap", "foo", "require"]

tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/typescript/enum/input.js
semantic error: Bindings mismatch:
Expand Down Expand Up @@ -122,16 +133,16 @@ rebuilt : []

tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/typescript/loc-index-property/input.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["AssertsFoo", "Foo"]
rebuilt : ScopeId(0): ["AssertsFoo"]
after transform: ScopeId(0): ["AssertsFoo", "Foo", "_defineProperty"]
rebuilt : ScopeId(0): ["AssertsFoo", "_defineProperty"]
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2)]
rebuilt : ScopeId(0): [ScopeId(1)]

tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/typescript/loc-index-property-babel-7/input.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["AssertsFoo", "Foo"]
rebuilt : ScopeId(0): ["AssertsFoo"]
after transform: ScopeId(0): ["AssertsFoo", "Foo", "_defineProperty"]
rebuilt : ScopeId(0): ["AssertsFoo", "_defineProperty"]
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2)]
rebuilt : ScopeId(0): [ScopeId(1)]
Expand Down Expand Up @@ -231,7 +242,7 @@ rebuilt : []
tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/input.ts
semantic error: Symbol reference IDs mismatch for "Foo":
after transform: SymbolId(0): [ReferenceId(0), ReferenceId(1)]
rebuilt : SymbolId(0): []
rebuilt : SymbolId(1): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var/input.ts
semantic error: Scope children mismatch:
Expand All @@ -253,22 +264,22 @@ semantic error: Bindings mismatch:
after transform: ScopeId(1): ["M"]
rebuilt : ScopeId(1): []
Symbol reference IDs mismatch for "AbstractClass":
after transform: SymbolId(0): [ReferenceId(0), ReferenceId(1), ReferenceId(3)]
rebuilt : SymbolId(0): [ReferenceId(0)]
after transform: SymbolId(0): [ReferenceId(0), ReferenceId(1), ReferenceId(3), ReferenceId(9)]
rebuilt : SymbolId(1): [ReferenceId(1), ReferenceId(2)]
Symbol reference IDs mismatch for "ConcreteClass":
after transform: SymbolId(2): [ReferenceId(4), ReferenceId(6)]
rebuilt : SymbolId(1): [ReferenceId(1)]
rebuilt : SymbolId(2): [ReferenceId(3)]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/assign/TSTypeParameterInstantiation-babel-7/input.ts
semantic error: Bindings mismatch:
after transform: ScopeId(1): ["M"]
rebuilt : ScopeId(1): []
Symbol reference IDs mismatch for "AbstractClass":
after transform: SymbolId(0): [ReferenceId(0), ReferenceId(1), ReferenceId(3)]
rebuilt : SymbolId(0): [ReferenceId(0)]
after transform: SymbolId(0): [ReferenceId(0), ReferenceId(1), ReferenceId(3), ReferenceId(9)]
rebuilt : SymbolId(1): [ReferenceId(1), ReferenceId(2)]
Symbol reference IDs mismatch for "ConcreteClass":
after transform: SymbolId(2): [ReferenceId(4), ReferenceId(6)]
rebuilt : SymbolId(1): [ReferenceId(1)]
rebuilt : SymbolId(2): [ReferenceId(3)]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/cast/as/input.ts
semantic error: Unresolved references mismatch:
Expand Down Expand Up @@ -315,8 +326,8 @@ rebuilt : ScopeId(5): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/async-named-properties/input.ts
semantic error: Scope children mismatch:
after transform: ScopeId(1): [ScopeId(2)]
rebuilt : ScopeId(1): []
after transform: ScopeId(1): [ScopeId(2), ScopeId(3)]
rebuilt : ScopeId(1): [ScopeId(2)]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/async-optional-method/input.js
semantic error: Scope children mismatch:
Expand Down Expand Up @@ -430,13 +441,13 @@ rebuilt : []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/members-with-modifier-names/input.ts
semantic error: Scope children mismatch:
after transform: ScopeId(1): [ScopeId(2), ScopeId(3), ScopeId(4)]
rebuilt : ScopeId(1): []
after transform: ScopeId(1): [ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5)]
rebuilt : ScopeId(1): [ScopeId(2)]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/members-with-modifier-names-babel-7/input.ts
semantic error: Scope children mismatch:
after transform: ScopeId(1): [ScopeId(2), ScopeId(3), ScopeId(4)]
rebuilt : ScopeId(1): []
after transform: ScopeId(1): [ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5)]
rebuilt : ScopeId(1): [ScopeId(2)]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/members-with-reserved-names/input.ts
semantic error: Scope children mismatch:
Expand Down Expand Up @@ -1447,18 +1458,18 @@ rebuilt : ScopeId(0): []
tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/input.ts
semantic error: Bindings mismatch:
after transform: ScopeId(2): ["T"]
rebuilt : ScopeId(2): []
rebuilt : ScopeId(3): []
Bindings mismatch:
after transform: ScopeId(3): ["T"]
rebuilt : ScopeId(3): []
rebuilt : ScopeId(4): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560-babel-7/input.ts
semantic error: Bindings mismatch:
after transform: ScopeId(2): ["T"]
rebuilt : ScopeId(2): []
rebuilt : ScopeId(3): []
Bindings mismatch:
after transform: ScopeId(3): ["T"]
rebuilt : ScopeId(3): []
rebuilt : ScopeId(4): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/destructuring-in-function-type/input.ts
semantic error: Bindings mismatch:
Expand Down Expand Up @@ -2264,11 +2275,11 @@ rebuilt : ["f"]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-asi/input.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["C", "C1", "C2", "C3", "C4", "I", "bar", "x10", "x11", "x12", "x13", "x14", "x5", "x6", "yy"]
rebuilt : ScopeId(0): ["C", "C1", "C2", "C3", "C4", "bar", "x10", "x11", "x12", "x13", "x14", "x5", "x6", "yy"]
after transform: ScopeId(0): ["C", "C1", "C2", "C3", "C4", "I", "_defineProperty", "bar", "x10", "x11", "x12", "x13", "x14", "x5", "x6", "yy"]
rebuilt : ScopeId(0): ["C", "C1", "C2", "C3", "C4", "_defineProperty", "bar", "x10", "x11", "x12", "x13", "x14", "x5", "x6", "yy"]
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6), ScopeId(7)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(6), ScopeId(8)]
Unresolved references mismatch:
after transform: ["f", "true"]
rebuilt : ["f"]
Expand Down
26 changes: 13 additions & 13 deletions tasks/coverage/snapshots/semantic_misc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ rebuilt : []

tasks/coverage/misc/pass/oxc-3948-1.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["BrowserWorkingCopyBackupTracker", "CancellationToken", "DisposableStore", "EditorPart", "EditorService", "IEditorGroupsService", "IEditorService", "IFilesConfigurationService", "IInstantiationService", "ILifecycleService", "ILogService", "IUntitledTextResourceEditorInput", "IWorkingCopyBackup", "IWorkingCopyBackupService", "IWorkingCopyEditorHandler", "IWorkingCopyEditorService", "IWorkingCopyService", "InMemoryTestWorkingCopyBackupService", "LifecyclePhase", "Schemas", "TestServiceAccessor", "TestWorkingCopy", "URI", "UntitledTextEditorInput", "VSBuffer", "_asyncToGenerator", "assert", "bufferToReadable", "createEditorPart", "ensureNoDisposablesAreLeakedInTestSuite", "isWindows", "registerTestResourceEditor", "timeout", "toResource", "toTypedWorkingCopyId", "toUntypedWorkingCopyId", "workbenchInstantiationService", "workbenchTeardown"]
rebuilt : ScopeId(0): ["BrowserWorkingCopyBackupTracker", "DisposableStore", "EditorService", "IEditorGroupsService", "IEditorService", "IFilesConfigurationService", "ILifecycleService", "ILogService", "IWorkingCopyBackupService", "IWorkingCopyEditorService", "IWorkingCopyService", "InMemoryTestWorkingCopyBackupService", "LifecyclePhase", "Schemas", "TestServiceAccessor", "TestWorkingCopy", "URI", "UntitledTextEditorInput", "VSBuffer", "_asyncToGenerator", "assert", "bufferToReadable", "createEditorPart", "ensureNoDisposablesAreLeakedInTestSuite", "isWindows", "registerTestResourceEditor", "timeout", "toResource", "toTypedWorkingCopyId", "toUntypedWorkingCopyId", "workbenchInstantiationService", "workbenchTeardown"]
after transform: ScopeId(0): ["BrowserWorkingCopyBackupTracker", "CancellationToken", "DisposableStore", "EditorPart", "EditorService", "IEditorGroupsService", "IEditorService", "IFilesConfigurationService", "IInstantiationService", "ILifecycleService", "ILogService", "IUntitledTextResourceEditorInput", "IWorkingCopyBackup", "IWorkingCopyBackupService", "IWorkingCopyEditorHandler", "IWorkingCopyEditorService", "IWorkingCopyService", "InMemoryTestWorkingCopyBackupService", "LifecyclePhase", "Schemas", "TestServiceAccessor", "TestWorkingCopy", "URI", "UntitledTextEditorInput", "VSBuffer", "_asyncToGenerator", "_defineProperty", "assert", "bufferToReadable", "createEditorPart", "ensureNoDisposablesAreLeakedInTestSuite", "isWindows", "registerTestResourceEditor", "timeout", "toResource", "toTypedWorkingCopyId", "toUntypedWorkingCopyId", "workbenchInstantiationService", "workbenchTeardown"]
rebuilt : ScopeId(0): ["BrowserWorkingCopyBackupTracker", "DisposableStore", "EditorService", "IEditorGroupsService", "IEditorService", "IFilesConfigurationService", "ILifecycleService", "ILogService", "IWorkingCopyBackupService", "IWorkingCopyEditorService", "IWorkingCopyService", "InMemoryTestWorkingCopyBackupService", "LifecyclePhase", "Schemas", "TestServiceAccessor", "TestWorkingCopy", "URI", "UntitledTextEditorInput", "VSBuffer", "_asyncToGenerator", "_defineProperty", "assert", "bufferToReadable", "createEditorPart", "ensureNoDisposablesAreLeakedInTestSuite", "isWindows", "registerTestResourceEditor", "timeout", "toResource", "toTypedWorkingCopyId", "toUntypedWorkingCopyId", "workbenchInstantiationService", "workbenchTeardown"]
Symbol reference IDs mismatch for "URI":
after transform: SymbolId(1): [ReferenceId(109), ReferenceId(117), ReferenceId(156), ReferenceId(158), ReferenceId(160), ReferenceId(162)]
rebuilt : SymbolId(1): [ReferenceId(158), ReferenceId(160), ReferenceId(162), ReferenceId(164)]
rebuilt : SymbolId(1): [ReferenceId(161), ReferenceId(163), ReferenceId(165), ReferenceId(167)]
Symbol reference IDs mismatch for "IEditorService":
after transform: SymbolId(2): [ReferenceId(23), ReferenceId(24), ReferenceId(67), ReferenceId(184)]
rebuilt : SymbolId(2): [ReferenceId(17), ReferenceId(58), ReferenceId(185)]
rebuilt : SymbolId(2): [ReferenceId(17), ReferenceId(60), ReferenceId(188)]
Symbol reference IDs mismatch for "IEditorGroupsService":
after transform: SymbolId(4): [ReferenceId(25), ReferenceId(26), ReferenceId(57), ReferenceId(176)]
rebuilt : SymbolId(3): [ReferenceId(18), ReferenceId(49), ReferenceId(178)]
rebuilt : SymbolId(3): [ReferenceId(18), ReferenceId(51), ReferenceId(181)]
Symbol reference IDs mismatch for "EditorService":
after transform: SymbolId(5): [ReferenceId(61), ReferenceId(64), ReferenceId(178), ReferenceId(181)]
rebuilt : SymbolId(4): [ReferenceId(55), ReferenceId(182)]
rebuilt : SymbolId(4): [ReferenceId(57), ReferenceId(185)]
Symbol reference IDs mismatch for "IWorkingCopyBackupService":
after transform: SymbolId(7): [ReferenceId(11), ReferenceId(12), ReferenceId(51), ReferenceId(170)]
rebuilt : SymbolId(5): [ReferenceId(11), ReferenceId(43), ReferenceId(172)]
rebuilt : SymbolId(5): [ReferenceId(11), ReferenceId(45), ReferenceId(175)]
Symbol reference IDs mismatch for "IFilesConfigurationService":
after transform: SymbolId(10): [ReferenceId(13), ReferenceId(14)]
rebuilt : SymbolId(8): [ReferenceId(12)]
Expand All @@ -87,19 +87,19 @@ after transform: SymbolId(17): [ReferenceId(38), ReferenceId(87)]
rebuilt : SymbolId(13): [ReferenceId(31)]
Symbol reference IDs mismatch for "InMemoryTestWorkingCopyBackupService":
after transform: SymbolId(19): [ReferenceId(43), ReferenceId(46), ReferenceId(165)]
rebuilt : SymbolId(15): [ReferenceId(38), ReferenceId(167)]
rebuilt : SymbolId(15): [ReferenceId(40), ReferenceId(170)]
Symbol reference IDs mismatch for "TestServiceAccessor":
after transform: SymbolId(21): [ReferenceId(1), ReferenceId(40), ReferenceId(71), ReferenceId(155), ReferenceId(188)]
rebuilt : SymbolId(17): [ReferenceId(62), ReferenceId(189)]
rebuilt : SymbolId(17): [ReferenceId(64), ReferenceId(192)]
Symbol reference IDs mismatch for "IWorkingCopyEditorService":
after transform: SymbolId(32): [ReferenceId(21), ReferenceId(22)]
rebuilt : SymbolId(26): [ReferenceId(16)]
Symbol reference IDs mismatch for "TestWorkingCopyBackupTracker":
after transform: SymbolId(39): [ReferenceId(42), ReferenceId(74), ReferenceId(154), ReferenceId(215)]
rebuilt : SymbolId(34): [ReferenceId(65), ReferenceId(216)]
rebuilt : SymbolId(35): [ReferenceId(67), ReferenceId(219)]
Unresolved reference IDs mismatch for "Promise":
after transform: [ReferenceId(36), ReferenceId(39), ReferenceId(82), ReferenceId(114), ReferenceId(153), ReferenceId(282)]
rebuilt : [ReferenceId(289)]
rebuilt : [ReferenceId(292)]

tasks/coverage/misc/pass/oxc-4449.ts
semantic error: Bindings mismatch:
Expand Down Expand Up @@ -185,8 +185,8 @@ rebuilt : ScopeId(0): [ScopeId(1)]

tasks/coverage/misc/pass/oxc-5955.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["B", "C", "a"]
rebuilt : ScopeId(0): ["B", "a"]
after transform: ScopeId(0): ["B", "C", "_defineProperty", "a"]
rebuilt : ScopeId(0): ["B", "_defineProperty", "a"]
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2)]
Expand Down
Loading

0 comments on commit 562abd5

Please sign in to comment.