Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions crates/oxc_transformer/src/decorator/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,13 @@ impl<'a> LegacyDecorator<'a> {
);
}

debug_assert!(
!self.emit_decorator_metadata || self.metadata.pop_constructor_metadata().is_none(),
"`pop_constructor_metadata` should be `None` because there are no class decorators, so no metadata was generated."
);
if self.emit_decorator_metadata {
let metadata = self.metadata.pop_constructor_metadata();
debug_assert!(
metadata.is_none(),
"`pop_constructor_metadata` should be `None` because there are no class decorators, so no metadata was generated."
);
}
}

/// Transforms a decorated class declaration and appends the resulting statements. If
Expand Down
24 changes: 22 additions & 2 deletions tasks/transform_conformance/snapshots/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: 87a048db

Passed: 204/336
Passed: 204/337

# All Passed:
* babel-plugin-transform-class-static-block
Expand Down Expand Up @@ -555,7 +555,7 @@ x Output mismatch
x Output mismatch


# legacy-decorators (6/87)
# legacy-decorators (6/88)
* oxc/class-without-name-with-decorated_class/input.ts
Bindings mismatch:
after transform: ScopeId(0): ["dec"]
Expand Down Expand Up @@ -854,6 +854,26 @@ Unresolved reference IDs mismatch for "babelHelpers":
after transform: [ReferenceId(7), ReferenceId(8), ReferenceId(9), ReferenceId(11), ReferenceId(13), ReferenceId(17), ReferenceId(18), ReferenceId(19), ReferenceId(20), ReferenceId(22), ReferenceId(24)]
rebuilt : [ReferenceId(0), ReferenceId(3), ReferenceId(5), ReferenceId(6), ReferenceId(8), ReferenceId(9), ReferenceId(12), ReferenceId(14), ReferenceId(16)]

* oxc/metadata/static-anonymous-class-expression/input.ts
Bindings mismatch:
after transform: ScopeId(0): ["A", "Foo", "_ref", "dec"]
rebuilt : ScopeId(0): ["A", "Foo", "_ref"]
Symbol reference IDs mismatch for "A":
after transform: SymbolId(1): [ReferenceId(4), ReferenceId(5), ReferenceId(6)]
rebuilt : SymbolId(1): [ReferenceId(7), ReferenceId(8)]
Symbol span mismatch for "Foo":
after transform: SymbolId(2): Span { start: 72, end: 75 }
rebuilt : SymbolId(2): Span { start: 0, end: 0 }
Symbol span mismatch for "Foo":
after transform: SymbolId(5): Span { start: 0, end: 0 }
rebuilt : SymbolId(3): Span { start: 72, end: 75 }
Reference symbol mismatch for "dec":
after transform: SymbolId(0) "dec"
rebuilt : <None>
Unresolved references mismatch:
after transform: ["ClassDecorator", "Error", "Object", "babelHelpers"]
rebuilt : ["Error", "Object", "babelHelpers", "dec"]

* oxc/metadata/this/input.ts
Symbol span mismatch for "Example":
after transform: SymbolId(0): Span { start: 6, end: 13 }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare function dec(): ClassDecorator;
class A {}

@dec()
export class Foo {
static Error1 = class extends Error {};
static Error2 = class extends Error {};

constructor(a: A) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var _ref;
class A {}
let Foo = class Foo {
static Error1 = class extends Error {};
static Error2 = class extends Error {};
constructor(a) {}
};
Foo = babelHelpers.decorate([dec(), babelHelpers.decorateMetadata("design:paramtypes", [typeof (_ref = typeof A !== "undefined" && A) === "function" ? _ref : Object])], Foo);
export { Foo };
Loading