aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/decorators.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/decorators.test.ts')
-rw-r--r--test/bun.js/decorators.test.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/bun.js/decorators.test.ts b/test/bun.js/decorators.test.ts
index 554904107..7342380ae 100644
--- a/test/bun.js/decorators.test.ts
+++ b/test/bun.js/decorators.test.ts
@@ -786,3 +786,33 @@ test("no decorators", () => {
expect(a).toBe(1);
expect(aa.b).toBe(300000);
});
+
+test("class constructor parameter properties", () => {
+ class A {
+ constructor(readonly d: string = "default") {
+ expect(d).toBe(d);
+ expect(this.d).toBe(d);
+ }
+ }
+
+ const a = new A("c");
+ expect(a.d).toBe("c");
+
+ class B extends A {}
+
+ const b = new B();
+ expect(b.d).toBe("default");
+
+ class C extends A {
+ constructor(public f: number) {
+ super();
+ expect(this.d).toBe("default");
+ expect(f).toBe(f);
+ expect(this.f).toBe(f);
+ }
+ }
+
+ const c = new C(5);
+ expect(c.d).toBe("default");
+ expect(c.f).toBe(5);
+});