diff options
author | 2022-02-27 03:37:31 -0800 | |
---|---|---|
committer | 2022-02-27 03:37:31 -0800 | |
commit | d91e8974130735fd43cd9c37d6147fe20f6b3290 (patch) | |
tree | bc0c4d03f3c2a066fe2d3be3c23e81bd3ab7fc7d /integration/bunjs-only-snippets/transpiler.test.js | |
parent | 953ddef4820e7a0d6cc2e99a9ece5bc4127b6592 (diff) | |
download | bun-d91e8974130735fd43cd9c37d6147fe20f6b3290.tar.gz bun-d91e8974130735fd43cd9c37d6147fe20f6b3290.tar.zst bun-d91e8974130735fd43cd9c37d6147fe20f6b3290.zip |
[TS Parser] Implement `constructor(private foo)`
Input:
```
class Foo {
constructor(public bar: string = "baz") {}
bar: number;
}
```
Output:
```
class Foo {
bar;
constructor(bar = "baz") {
this.bar = bar;
}
baz;
}
```
Diffstat (limited to 'integration/bunjs-only-snippets/transpiler.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/transpiler.test.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js index f510cef74..34120e2d2 100644 --- a/integration/bunjs-only-snippets/transpiler.test.js +++ b/integration/bunjs-only-snippets/transpiler.test.js @@ -765,6 +765,27 @@ describe("Bun.Transpiler", () => { expectPrinted_("delete foo?.bar?.baz", "delete foo?.bar?.baz"); }); + it("useDefineForConst TypeScript class initialization", () => { + var { expectPrinted_ } = ts; + expectPrinted_( + ` +class Foo { + constructor(public x: string = "hey") {} + bar: number; +} +`.trim(), + ` +class Foo { + x; + constructor(x = "hey") { + this.x = x; + } + bar; +} +`.trim() + ); + }); + it("class static blocks", () => { expectPrinted_( "class Foo { static {} }", |