aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-09-21 12:20:53 -0700
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-09-21 12:20:53 -0700
commit4a1573e007f984a9c1eb11a5fa003f73e84dc975 (patch)
treeb6531d739a5e2c66dcdc468691b6839531f0a9b9 /test
parent0b4a34bbd6e07096212774759ca6e8a7f3922e46 (diff)
downloadbun-4a1573e007f984a9c1eb11a5fa003f73e84dc975.tar.gz
bun-4a1573e007f984a9c1eb11a5fa003f73e84dc975.tar.zst
bun-4a1573e007f984a9c1eb11a5fa003f73e84dc975.zip
decorator metadata defaults and rest args
Diffstat (limited to 'test')
-rw-r--r--test/transpiler/decorator-metadata.test.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/transpiler/decorator-metadata.test.ts b/test/transpiler/decorator-metadata.test.ts
index 861604430..9cc8cc718 100644
--- a/test/transpiler/decorator-metadata.test.ts
+++ b/test/transpiler/decorator-metadata.test.ts
@@ -491,4 +491,56 @@ describe("decorator metadata", () => {
expect(Reflect.getMetadata("design:returntype", A.prototype, "method1")).toBe(Promise);
});
+
+ test("rest parameters and defaults", () => {
+ function d1(target: any) {}
+ function d2(target: any, key: string) {}
+
+ @d1
+ class A {
+ @d2
+ // @ts-ignore
+ prop0: any[];
+
+ // @ts-ignore
+ constructor(a0) {}
+
+ @d2
+ // @ts-ignore
+ prop1;
+
+ @d2
+ method1() {}
+
+ @d2
+ // @ts-ignore
+ method2(...a0) {}
+
+ @d2
+ method3(a0: number, ...a1: []) {}
+
+ @d2
+ method4(...a0: any[]) {}
+ }
+
+ expect(Reflect.getMetadata("design:type", A.prototype, "prop0")).toBe(Array);
+ expect(Reflect.getMetadata("design:type", A.prototype, "prop1")).toBe(Object);
+
+ expect(Reflect.getMetadata("design:paramtypes", A.prototype, "method1")).toHaveLength(0);
+ expect(Reflect.getMetadata("design:type", A.prototype, "method1")).toBe(Function);
+ expect(Reflect.getMetadata("design:returntype", A.prototype, "method1")).toBeUndefined();
+
+ expect(Reflect.getMetadata("design:paramtypes", A.prototype, "method2")[0]).toBe(Object);
+ expect(Reflect.getMetadata("design:type", A.prototype, "method2")).toBe(Function);
+ expect(Reflect.getMetadata("design:returntype", A.prototype, "method2")).toBeUndefined();
+
+ expect(Reflect.getMetadata("design:paramtypes", A.prototype, "method3")[0]).toBe(Number);
+ expect(Reflect.getMetadata("design:paramtypes", A.prototype, "method3")[1]).toBe(Object);
+ expect(Reflect.getMetadata("design:type", A.prototype, "method3")).toBe(Function);
+ expect(Reflect.getMetadata("design:returntype", A.prototype, "method3")).toBeUndefined();
+
+ expect(Reflect.getMetadata("design:paramtypes", A.prototype, "method4")[0]).toBe(Object);
+ expect(Reflect.getMetadata("design:type", A.prototype, "method4")).toBe(Function);
+ expect(Reflect.getMetadata("design:returntype", A.prototype, "method4")).toBeUndefined();
+ });
});