diff options
author | 2023-01-20 16:24:40 -0800 | |
---|---|---|
committer | 2023-01-20 16:24:40 -0800 | |
commit | b8648adf873758a83911d3d28c94255d8c3fdd3c (patch) | |
tree | 4705ec06520a59fbf66bb2b84ba6c08bd984c981 /test/bun.js | |
parent | ff6fb587f6c253c7bc849071ace593a473da5370 (diff) | |
download | bun-b8648adf873758a83911d3d28c94255d8c3fdd3c.tar.gz bun-b8648adf873758a83911d3d28c94255d8c3fdd3c.tar.zst bun-b8648adf873758a83911d3d28c94255d8c3fdd3c.zip |
constructor parameter properties in class expressions (#1867)
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/decorators.test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/bun.js/decorators.test.ts b/test/bun.js/decorators.test.ts index 7342380ae..8a2bc6d9a 100644 --- a/test/bun.js/decorators.test.ts +++ b/test/bun.js/decorators.test.ts @@ -816,3 +816,32 @@ test("class constructor parameter properties", () => { expect(c.d).toBe("default"); expect(c.f).toBe(5); }); + +test("class expressions are lowered correctly (no decorators)", () => { + const A = class a { + constructor(readonly b: string = "default") { + expect(b).toBe(b); + expect(this.b).toBe(b); + } + }; + + const a = new A("hello class expression"); + expect(a.b).toBe("hello class expression"); + + const B = class b extends A {}; + const b = new B(); + expect(b.b).toBe("default"); + + const C = class c extends A { + constructor(public f: number) { + super(); + expect(this.b).toBe("default"); + expect(this.f).toBe(f); + expect(f).toBe(f); + } + }; + + const c = new C(5); + expect(c.b).toBe("default"); + expect(c.f).toBe(5); +}); |