aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-04-17 15:26:18 -0700
committerGravatar GitHub <noreply@github.com> 2023-04-17 15:26:18 -0700
commit1ce60275d083665ce0988969c2e97c5fae8daa95 (patch)
treeecd1887548bb59d0da39e58ba5dc9c7bd325a024 /test
parent93a43c8fc1864e8460839fc952763a31115fae20 (diff)
downloadbun-1ce60275d083665ce0988969c2e97c5fae8daa95.tar.gz
bun-1ce60275d083665ce0988969c2e97c5fae8daa95.tar.zst
bun-1ce60275d083665ce0988969c2e97c5fae8daa95.zip
fix typescript decorators with index and number keys (#2677)
* handle index property key case * non-method number property * tests for property keys
Diffstat (limited to 'test')
-rw-r--r--test/bundler/decorators.test.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/bundler/decorators.test.ts b/test/bundler/decorators.test.ts
index 134ae73ac..8769ea2bc 100644
--- a/test/bundler/decorators.test.ts
+++ b/test/bundler/decorators.test.ts
@@ -706,6 +706,37 @@ test("only class decorator", () => {
expect(a).toBe(1);
});
+test("decorators with different property key types", () => {
+ function d1(x) {
+ return function (target, propertyKey) {
+ expect(propertyKey).toBeDefined();
+ expect(propertyKey).toBe(x);
+ };
+ }
+ function foo(x, y, z) {
+ class A {
+ @d1(arguments[0])
+ [arguments[0]]() {}
+ @d1(y)
+ [y] = 10;
+ @d1(z)
+ [arguments[2]] = 20;
+ @d1("string")
+ "string" = 30;
+ @d1("string method")
+ "string method"() {}
+ @d1(12e3)
+ 12e3 = "number key";
+ @d1(12e3 + 1)
+ [12e3 + 1]() {}
+ }
+
+ return A;
+ }
+
+ let A = foo("a", "b", "c");
+});
+
test("only property decorators", () => {
let a = 0;
class A {