From ff8896e364c9a8d16b7c2231c32c0d1b5df904f2 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Tue, 18 Feb 2025 09:26:53 +0800 Subject: [PATCH] test(transformer/legacy-decorator): update update-fixtures for emitDecoratorMetadata --- .../decoratorOnClassAccessor8/options.json | 10 ++++++++ .../decoratorOnClassAccessor8/output.js | 24 +++++++++---------- .../decoratorOnClassConstructor4/options.json | 10 ++++++++ .../decoratorOnClassConstructor4/output.js | 2 +- .../decoratedBlockScopedClass1/options.json | 10 ++++++++ .../decoratedBlockScopedClass2/options.json | 10 ++++++++ .../decoratedBlockScopedClass3/options.json | 10 ++++++++ .../options.json | 10 ++++++++ .../options.json | 10 ++++++++ .../decoratedClassExportsSystem1/options.json | 10 ++++++++ .../decoratedClassExportsSystem2/options.json | 10 ++++++++ .../decoratorOnClassMethod14/options.json | 10 ++++++++ .../method/decoratorOnClassMethod14/output.js | 6 ++--- .../decoratorOnClassMethod15/options.json | 10 ++++++++ .../method/decoratorOnClassMethod15/output.js | 6 ++--- .../decoratorOnClassMethod16/options.json | 10 ++++++++ .../method/decoratorOnClassMethod16/output.js | 6 ++--- .../decoratorOnClassMethod17/options.json | 10 ++++++++ .../method/decoratorOnClassMethod17/output.js | 6 ++--- .../decoratorOnClassMethod18/options.json | 10 ++++++++ .../method/decoratorOnClassMethod18/output.js | 2 +- .../decoratorOnClassMethod19/options.json | 10 ++++++++ .../method/decoratorOnClassMethod19/output.js | 12 +++++----- .../decoratorOnClassProperty12/options.json | 10 ++++++++ .../decoratorOnClassProperty12/output.js | 2 +- .../test/fixtures/update-fixtures.js | 23 ++++++++++++++---- 26 files changed, 211 insertions(+), 38 deletions(-) create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass1/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass2/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass3/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS1/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS2/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem1/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem2/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/options.json create mode 100644 tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/options.json diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/output.js index 5512be4d098a6..eedf54c7dcefb 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/accessor/decoratorOnClassAccessor8/output.js @@ -4,8 +4,8 @@ class A { } babelHelpers.decorate([ dec, - __metadata("design:type", Number), - __metadata("design:paramtypes", [Number]) + babelHelpers.decorateMetadata("design:type", Number), + babelHelpers.decorateMetadata("design:paramtypes", [Number]) ], A.prototype, "x", null); class B { get x() { return 0; } @@ -13,8 +13,8 @@ class B { } babelHelpers.decorate([ dec, - __metadata("design:type", Number), - __metadata("design:paramtypes", [Number]) + babelHelpers.decorateMetadata("design:type", Number), + babelHelpers.decorateMetadata("design:paramtypes", [Number]) ], B.prototype, "x", null); class C { set x(value) { } @@ -22,8 +22,8 @@ class C { } babelHelpers.decorate([ dec, - __metadata("design:type", Number), - __metadata("design:paramtypes", [Number]) + babelHelpers.decorateMetadata("design:type", Number), + babelHelpers.decorateMetadata("design:paramtypes", [Number]) ], C.prototype, "x", null); class D { set x(value) { } @@ -31,22 +31,22 @@ class D { } babelHelpers.decorate([ dec, - __metadata("design:type", Number), - __metadata("design:paramtypes", [Number]) + babelHelpers.decorateMetadata("design:type", Number), + babelHelpers.decorateMetadata("design:paramtypes", [Number]) ], D.prototype, "x", null); class E { get x() { return 0; } } babelHelpers.decorate([ dec, - __metadata("design:type", Object), - __metadata("design:paramtypes", []) + babelHelpers.decorateMetadata("design:type", Object), + babelHelpers.decorateMetadata("design:paramtypes", []) ], E.prototype, "x", null); class F { set x(value) { } } babelHelpers.decorate([ dec, - __metadata("design:type", Number), - __metadata("design:paramtypes", [Number]) + babelHelpers.decorateMetadata("design:type", Number), + babelHelpers.decorateMetadata("design:paramtypes", [Number]) ], F.prototype, "x", null); diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/output.js index 7f35d6d97fc79..51a1f81d4b609 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/constructor/decoratorOnClassConstructor4/output.js @@ -8,7 +8,7 @@ let B = class B { }; B = babelHelpers.decorate([ dec, - __metadata("design:paramtypes", [Number]) + babelHelpers.decorateMetadata("design:paramtypes", [Number]) ], B); let C = class C extends A { }; diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass1/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass1/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass1/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass2/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass2/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass2/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass3/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass3/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedBlockScopedClass3/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS1/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS1/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS1/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS2/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS2/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsCommonJS2/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem1/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem1/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem1/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem2/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem2/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/decoratedClassExportsSystem2/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/output.js index 2fbc7108fe5e9..144698fba4953 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod14/output.js @@ -8,7 +8,7 @@ class Foo { } babelHelpers.decorate([ decorator, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) + babelHelpers.decorateMetadata("design:type", Function), + babelHelpers.decorateMetadata("design:paramtypes", []), + babelHelpers.decorateMetadata("design:returntype", void 0) ], Foo.prototype, "foo", null); diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/output.js index e413660308a61..3f6fd0a31a10c 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod15/output.js @@ -6,7 +6,7 @@ class Foo { } babelHelpers.decorate([ decorator, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) + babelHelpers.decorateMetadata("design:type", Function), + babelHelpers.decorateMetadata("design:paramtypes", []), + babelHelpers.decorateMetadata("design:returntype", void 0) ], Foo.prototype, "foo", null); diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/output.js index d01ba25357894..1a2916467949b 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod16/output.js @@ -6,7 +6,7 @@ class Foo { } babelHelpers.decorate([ decorator, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) + babelHelpers.decorateMetadata("design:type", Function), + babelHelpers.decorateMetadata("design:paramtypes", []), + babelHelpers.decorateMetadata("design:returntype", void 0) ], Foo.prototype, "foo", null); diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/output.js index d01ba25357894..1a2916467949b 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod17/output.js @@ -6,7 +6,7 @@ class Foo { } babelHelpers.decorate([ decorator, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) + babelHelpers.decorateMetadata("design:type", Function), + babelHelpers.decorateMetadata("design:paramtypes", []), + babelHelpers.decorateMetadata("design:returntype", void 0) ], Foo.prototype, "foo", null); diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/output.js index c8013952470dd..3c8506e80c65b 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod18/output.js @@ -4,5 +4,5 @@ class Foo { } babelHelpers.decorate([ decorator(), - __metadata("design:type", Object) + babelHelpers.decorateMetadata("design:type", Object) ], Foo.prototype, "p2", void 0); diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/output.js index 7e6b24861b921..972779c746303 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/method/decoratorOnClassMethod19/output.js @@ -7,9 +7,9 @@ class C1 { static { babelHelpers.decorate([ decorator((x) => x.#x), - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) + babelHelpers.decorateMetadata("design:type", Function), + babelHelpers.decorateMetadata("design:paramtypes", []), + babelHelpers.decorateMetadata("design:returntype", void 0) ], C1.prototype, "y", null); } } @@ -19,9 +19,9 @@ class C2 { static { babelHelpers.decorate([ babelHelpers.decorateParam(0, decorator((x) => x.#x)), - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", void 0) + babelHelpers.decorateMetadata("design:type", Function), + babelHelpers.decorateMetadata("design:paramtypes", [Object]), + babelHelpers.decorateMetadata("design:returntype", void 0) ], C2.prototype, "y", null); } } diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/options.json b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/options.json new file mode 100644 index 0000000000000..447e6fe72c11f --- /dev/null +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "transform-legacy-decorator", + { + "emitDecoratorMetadata": true + } + ] + ] +} \ No newline at end of file diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/output.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/output.js index 27beab57e610f..c6c067a39a858 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/output.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/typescript/property/decoratorOnClassProperty12/output.js @@ -3,5 +3,5 @@ class A { } babelHelpers.decorate([ dec(), - __metadata("design:type", String) + babelHelpers.decorateMetadata("design:type", String) ], A.prototype, "foo", void 0); diff --git a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/update-fixtures.js b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/update-fixtures.js index 3dd8f2e95cd36..3a65088561cd1 100644 --- a/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/update-fixtures.js +++ b/tasks/transform_conformance/tests/legacy-decorators/test/fixtures/update-fixtures.js @@ -56,11 +56,19 @@ function copyTestsFromTypeScript() { } } -function writeBabelOptions(folder) { +function writeBabelOptions(folder, emitDecoratorMetadata = false) { const optionsFile = join(folder, "options.json"); - const content = JSON.stringify({ - plugins: ["transform-legacy-decorator"], - }, null, 2); + const legacyDecoratorPlugin = [ + "transform-legacy-decorator", + emitDecoratorMetadata ? { emitDecoratorMetadata: true } : null, + ].filter(Boolean); + const content = JSON.stringify( + { + plugins: [legacyDecoratorPlugin.length === 1 ? legacyDecoratorPlugin[0] : legacyDecoratorPlugin], + }, + null, + 2, + ); writeFileSync(optionsFile, content); } @@ -75,6 +83,10 @@ async function generateOutputFiles() { const emitDecoratorMetadata = /\@emitDecoratorMetadata/gi.test(source); + if (emitDecoratorMetadata) { + writeBabelOptions(dirname(inputFile), true); + } + /// Generate the output file path by using `typescript` library, and we need to set target to esnext const output = transpileModule(source, { compilerOptions: { @@ -88,7 +100,8 @@ async function generateOutputFiles() { // Rename helper functions to our own const outputText = output.outputText .replaceAll("__decorate(", "babelHelpers.decorate(") - .replaceAll("__param(", "babelHelpers.decorateParam("); + .replaceAll("__param(", "babelHelpers.decorateParam(") + .replaceAll("__metadata(", "babelHelpers.decorateMetadata("); const outputFile = join(dirname(inputFile), "output.js"); writeFileSync(outputFile, outputText);