Skip to content

Commit

Permalink
fix(transformer): class property with typescript value should not be …
Browse files Browse the repository at this point in the history
…removed (#5298)
  • Loading branch information
Boshen committed Aug 28, 2024
1 parent 7009177 commit 8d6b05c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
4 changes: 1 addition & 3 deletions crates/oxc_transformer/src/typescript/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ impl<'a> TypeScriptAnnotations<'a> {
&& !method.value.is_typescript_syntax()
}
ClassElement::PropertyDefinition(prop) => {
if prop.value.as_ref().is_some_and(Expression::is_typescript_syntax)
|| prop.declare && prop.decorators.is_empty()
{
if prop.declare {
false
} else {
matches!(prop.r#type, PropertyDefinitionType::PropertyDefinition)
Expand Down
3 changes: 0 additions & 3 deletions tasks/coverage/semantic_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1681,9 +1681,6 @@ rebuilt : ScopeId(0): ["C", "C1", "C2", "C3", "C4", "bar", "x10", "x11",
Unresolved references mismatch:
after transform: ["f", "true"]
rebuilt : ["f"]
Unresolved reference IDs mismatch for "f":
after transform: [ReferenceId(0), ReferenceId(2), ReferenceId(4), ReferenceId(6), ReferenceId(8), ReferenceId(10), ReferenceId(13), ReferenceId(16), ReferenceId(17), ReferenceId(18), ReferenceId(19)]
rebuilt : [ReferenceId(0), ReferenceId(1), ReferenceId(2), ReferenceId(3), ReferenceId(4), ReferenceId(5), ReferenceId(7)]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-binary-operator/input.ts
semantic error: Unresolved references mismatch:
Expand Down
30 changes: 9 additions & 21 deletions tasks/coverage/semantic_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: d8086f14

semantic_typescript Summary:
AST Parsed : 6456/6456 (100.00%)
Positive Passed: 3441/6456 (53.30%)
Positive Passed: 3444/6456 (53.35%)
tasks/coverage/typescript/tests/cases/compiler/2dArrays.ts
semantic error: Symbol reference IDs mismatch:
after transform: SymbolId(0): [ReferenceId(1)]
Expand Down Expand Up @@ -26869,26 +26869,6 @@ Unresolved references mismatch:
after transform: ["Object"]
rebuilt : []

tasks/coverage/typescript/tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers1.ts
semantic error: Unresolved references mismatch:
after transform: ["B", "undefined"]
rebuilt : ["B"]

tasks/coverage/typescript/tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers2.ts
semantic error: Unresolved references mismatch:
after transform: ["B", "undefined"]
rebuilt : ["B"]

tasks/coverage/typescript/tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers3.ts
semantic error: Unresolved references mismatch:
after transform: ["B", "undefined"]
rebuilt : ["B"]

tasks/coverage/typescript/tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers4.ts
semantic error: Unresolved references mismatch:
after transform: ["B", "undefined"]
rebuilt : ["B"]

tasks/coverage/typescript/tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInInstanceMember2.ts
semantic error: Bindings mismatch:
after transform: ScopeId(1): ["T"]
Expand Down Expand Up @@ -27803,6 +27783,14 @@ semantic error: Unresolved references mismatch:
after transform: ["PropertyDescriptor", "dec"]
rebuilt : ["dec"]

tasks/coverage/typescript/tests/cases/conformance/decorators/decoratorInAmbientContext.ts
semantic error: Symbol reference IDs mismatch:
after transform: SymbolId(2): [ReferenceId(3)]
rebuilt : SymbolId(0): []
Unresolved references mismatch:
after transform: ["Symbol", "decorator"]
rebuilt : ["Symbol"]

tasks/coverage/typescript/tests/cases/conformance/decorators/decoratorMetadata.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["MyComponent", "Service", "decorator"]
Expand Down
10 changes: 8 additions & 2 deletions tasks/transform_conformance/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
commit: 12619ffe

Passed: 10/36
Passed: 10/37

# All Passed:
* babel-plugin-transform-optional-catch-binding
* babel-plugin-transform-arrow-functions


# babel-plugin-transform-typescript (2/7)
# babel-plugin-transform-typescript (2/8)
* class-property-definition/input.ts
x Unresolved references mismatch:
| after transform: ["const"]
| rebuilt : []


* computed-constant-value/input.ts
x Missing ReferenceId: Infinity

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Foo {
#handlers = [] as const;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Foo {
#handlers = [];
}

0 comments on commit 8d6b05c

Please sign in to comment.