diff options
author | 2023-07-08 17:41:24 -0700 | |
---|---|---|
committer | 2023-07-08 17:41:24 -0700 | |
commit | 59570fe237f91dd04ce8f37779902cffa4352010 (patch) | |
tree | 05db3a38804a141296eca211ea42aeb7dbd0aa82 /test | |
parent | aa8b832ef61ada31176d248e716074ff22bb9dee (diff) | |
download | bun-59570fe237f91dd04ce8f37779902cffa4352010.tar.gz bun-59570fe237f91dd04ce8f37779902cffa4352010.tar.zst bun-59570fe237f91dd04ce8f37779902cffa4352010.zip |
Handle case with TS decorators and export default anonymous class (#3578)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/transpiler/decorator-export-default-class-fixture-anon.ts | 10 | ||||
-rw-r--r-- | test/transpiler/decorators.test.ts | 7 | ||||
-rw-r--r-- | test/transpiler/export-default-with-static-initializer.js | 5 | ||||
-rw-r--r-- | test/transpiler/export-default.test.js | 6 |
4 files changed, 27 insertions, 1 deletions
diff --git a/test/transpiler/decorator-export-default-class-fixture-anon.ts b/test/transpiler/decorator-export-default-class-fixture-anon.ts new file mode 100644 index 000000000..bf81afa2c --- /dev/null +++ b/test/transpiler/decorator-export-default-class-fixture-anon.ts @@ -0,0 +1,10 @@ +function decorator(target: any, propertyKey: any) { + target[propertyKey + "decorated"] = true; +} + +export default class { + @decorator + method() { + return 42; + } +} diff --git a/test/transpiler/decorators.test.ts b/test/transpiler/decorators.test.ts index ad0980930..100ecc3bc 100644 --- a/test/transpiler/decorators.test.ts +++ b/test/transpiler/decorators.test.ts @@ -1,6 +1,7 @@ // @ts-nocheck import { test, expect, describe } from "bun:test"; import DecoratedClass from "./decorator-export-default-class-fixture"; +import DecoratedAnonClass from "./decorator-export-default-class-fixture-anon"; test("decorator order of evaluation", () => { let counter = 0; @@ -990,6 +991,10 @@ describe("constructor statements", () => { }); }); -test("export default class works", () => { +test("export default class Named works", () => { expect(new DecoratedClass()["methoddecorated"]).toBe(true); }); + +test("export default class works (anonymous name)", () => { + expect(new DecoratedAnonClass()["methoddecorated"]).toBe(true); +}); diff --git a/test/transpiler/export-default-with-static-initializer.js b/test/transpiler/export-default-with-static-initializer.js new file mode 100644 index 000000000..2d390b008 --- /dev/null +++ b/test/transpiler/export-default-with-static-initializer.js @@ -0,0 +1,5 @@ +export default class { + static { + this.boop = "boop"; + } +} diff --git a/test/transpiler/export-default.test.js b/test/transpiler/export-default.test.js new file mode 100644 index 000000000..e557ffe00 --- /dev/null +++ b/test/transpiler/export-default.test.js @@ -0,0 +1,6 @@ +import WithStatic from "./export-default-with-static-initializer"; +import { test, expect } from "bun:test"; + +test("static initializer", () => { + expect(WithStatic.boop).toBe("boop"); +}); |