aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-04-09 03:43:04 -0700
committerGravatar GitHub <noreply@github.com> 2023-04-09 03:43:04 -0700
commit21acc50d88d79de9a0576ad9d78eb5123f870df7 (patch)
tree682a38bc317446bbbf0cf6698c9a83dc70abac6d /test
parentb34f0da49959cd09b2f4fdc793e8f7dec357eadc (diff)
downloadbun-21acc50d88d79de9a0576ad9d78eb5123f870df7.tar.gz
bun-21acc50d88d79de9a0576ad9d78eb5123f870df7.tar.zst
bun-21acc50d88d79de9a0576ad9d78eb5123f870df7.zip
Fixes #2594 (#2600)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test')
-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");