diff options
author | 2023-04-17 15:26:18 -0700 | |
---|---|---|
committer | 2023-04-17 15:26:18 -0700 | |
commit | 1ce60275d083665ce0988969c2e97c5fae8daa95 (patch) | |
tree | ecd1887548bb59d0da39e58ba5dc9c7bd325a024 /test | |
parent | 93a43c8fc1864e8460839fc952763a31115fae20 (diff) | |
download | bun-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.ts | 31 |
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 { |