Skip to content

Commit e959420

Browse files
committed
fix(transformer/legacy-decorator): abstract class doesn't work in metadata
1 parent bed3f47 commit e959420

5 files changed

Lines changed: 32 additions & 4 deletions

File tree

crates/oxc_transformer/src/decorator/legacy/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a, 'ctx> LegacyDecoratorMetadata<'a, 'ctx> {
107107

108108
impl<'a> Traverse<'a> for LegacyDecoratorMetadata<'a, '_> {
109109
fn enter_class(&mut self, class: &mut Class<'a>, ctx: &mut TraverseCtx<'a>) {
110-
if class.is_expression() || class.is_typescript_syntax() {
110+
if class.is_expression() || class.declare {
111111
return;
112112
}
113113

crates/oxc_transformer/src/decorator/legacy/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ impl<'a> LegacyDecorator<'a, '_> {
808808
/// Check if a class or its elements have decorators.
809809
fn check_class_has_decorated(class: &Class<'a>) -> ClassDecoratorInfo {
810810
// Legacy decorator does not allow in class expression.
811-
if class.is_expression() || class.is_typescript_syntax() {
811+
if class.is_expression() || class.declare {
812812
return ClassDecoratorInfo::default();
813813
}
814814

tasks/transform_conformance/snapshots/oxc.snap.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
commit: 578ac4df
22

3-
Passed: 152/253
3+
Passed: 152/254
44

55
# All Passed:
66
* babel-plugin-transform-class-static-block
@@ -497,7 +497,18 @@ after transform: SymbolId(4): ScopeId(1)
497497
rebuilt : SymbolId(5): ScopeId(4)
498498

499499

500-
# legacy-decorators (4/73)
500+
# legacy-decorators (4/74)
501+
* oxc/metadata/abstrct-class/input.ts
502+
Bindings mismatch:
503+
after transform: ScopeId(0): ["AbstractClass", "Dependency", "dce"]
504+
rebuilt : ScopeId(0): ["AbstractClass", "dce"]
505+
Symbol span mismatch for "AbstractClass":
506+
after transform: SymbolId(2): Span { start: 74, end: 87 }
507+
rebuilt : SymbolId(1): Span { start: 0, end: 0 }
508+
Symbol span mismatch for "AbstractClass":
509+
after transform: SymbolId(4): Span { start: 0, end: 0 }
510+
rebuilt : SymbolId(2): Span { start: 74, end: 87 }
511+
501512
* oxc/metadata/bound-type-reference/input.ts
502513
Symbol reference IDs mismatch for "BoundTypeReference":
503514
after transform: SymbolId(0): [ReferenceId(1), ReferenceId(3), ReferenceId(4), ReferenceId(5), ReferenceId(6)]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { dce, type Dependency } from "mod";
2+
3+
@dce()
4+
export abstract class AbstractClass {
5+
constructor(public dependency: Dependency) {}
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { dce } from "mod";
2+
let AbstractClass = class AbstractClass {
3+
constructor(dependency) {
4+
this.dependency = dependency;
5+
}
6+
};
7+
AbstractClass = babelHelpers.decorate(
8+
[dce(), babelHelpers.decorateMetadata("design:paramtypes", [Object])],
9+
AbstractClass,
10+
);
11+
export { AbstractClass };

0 commit comments

Comments
 (0)