aboutsummaryrefslogtreecommitdiff
path: root/test/bundler/transpiler.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-04-09 03:43:04 -0700
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-04-10 11:58:19 -0700
commite5c431f52ea2559b9c8cf6ac2496c1a62b8b1cf8 (patch)
treef231ef950b82f668e99a6fd5a17732117fad48fb /test/bundler/transpiler.test.js
parent57d0f2da7e532dd29c60575ef0739558a5b4aa93 (diff)
downloadbun-e5c431f52ea2559b9c8cf6ac2496c1a62b8b1cf8.tar.gz
bun-e5c431f52ea2559b9c8cf6ac2496c1a62b8b1cf8.tar.zst
bun-e5c431f52ea2559b9c8cf6ac2496c1a62b8b1cf8.zip
Fixes #2594 (#2600)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/bundler/transpiler.test.js')
-rw-r--r--test/bundler/transpiler.test.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/bundler/transpiler.test.js b/test/bundler/transpiler.test.js
index 85c7affdb..7d05c2e65 100644
--- a/test/bundler/transpiler.test.js
+++ b/test/bundler/transpiler.test.js
@@ -73,6 +73,22 @@ describe("Bun.Transpiler", () => {
ts.expectPrinted_("console.log(`\r\n\r\n\r\n`)", "console.log(`\n\n\n`);\n");
});
+ describe("property access inlining", () => {
+ it("bails out with spread", () => {
+ ts.expectPrinted_("const a = [...b][0];", "const a = [...b][0]");
+ ts.expectPrinted_("const a = {...b}[0];", "const a = { ...b }[0]");
+ });
+ it("bails out with multiple items", () => {
+ ts.expectPrinted_("const a = [b, c][0];", "const a = [b, c][0]");
+ });
+ it("works", () => {
+ ts.expectPrinted_('const a = ["hey"][0];', 'const a = "hey"');
+ });
+ it("works nested", () => {
+ ts.expectPrinted_('const a = ["hey"][0][0];', 'const a = "h"');
+ });
+ });
+
describe("TypeScript", () => {
it("import Foo = Baz.Bar", () => {
ts.expectPrinted_("import Foo = Baz.Bar;\nexport default Foo;", "const Foo = Baz.Bar;\nexport default Foo");