Skip to content

Commit

Permalink
test(transformer/legacy-decorator): add an exec test that verifies it…
Browse files Browse the repository at this point in the history
… working with reflect-metadata well.
  • Loading branch information
Dunqing committed Feb 19, 2025
1 parent fbf1f31 commit b3c9443
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 4 deletions.
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tasks/transform_conformance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"@babel/plugin-transform-optional-chaining": "^7.25.9",
"@babel/plugin-transform-private-methods": "^7.25.9",
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
"@oxc-project/runtime": "link:../../npm/runtime"
"@oxc-project/runtime": "link:../../npm/runtime",
"reflect-metadata": "^0.2.2"
},
"dependencies": {
"@babel/plugin-transform-typescript": "^7.26.3"
Expand Down
4 changes: 2 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: acbc09a8

Passed: 135/219
Passed: 136/220

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


# legacy-decorators (0/62)
# legacy-decorators (1/63)
* typescript/accessor/decoratorOnClassAccessor1/input.ts
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2)]
Expand Down
2 changes: 1 addition & 1 deletion tasks/transform_conformance/snapshots/oxc_exec.snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: acbc09a8

node: v22.14.0

Passed: 5 of 7 (71.43%)
Passed: 6 of 8 (75.00%)

Failures:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"plugins": [
[
"transform-legacy-decorator",
{
"emitDecoratorMetadata": true
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "reflect-metadata";

function dce() {
}

class Example {
@dce
count: number = 0;

@dce
message: string = "";
}

const example = new Example();

expect(Reflect.getMetadata("design:type", example, "count")).toBe(Number);
expect(Reflect.getMetadata("design:type", example, "message")).toBe(String);

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "reflect-metadata";

function dce() {
}

class Example {
@dce
count: number = 0;

@dce
message: string = "";
}

const example = new Example();

expect(Reflect.getMetadata("design:type", example, "count")).toBe(Number);
expect(Reflect.getMetadata("design:type", example, "message")).toBe(String);

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import "reflect-metadata";

function dce() {}

class Example {
count = 0;
message = "";
}

babelHelpers.decorate([dce, babelHelpers.decorateMetadata("design:type", Number)], Example.prototype, "count", void 0);
babelHelpers.decorate([dce, babelHelpers.decorateMetadata("design:type", String)], Example.prototype, "message", void 0);

const example = new Example();

expect(Reflect.getMetadata("design:type", example, "count")).toBe(Number);
expect(Reflect.getMetadata("design:type", example, "message")).toBe(String);

0 comments on commit b3c9443

Please sign in to comment.