Skip to content

Commit c4ebb44

Browse files
committed
test: build server function with unused destructured variable
1 parent 02b1763 commit c4ebb44

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

apps/tests/src/e2e/server-function.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,11 @@ test.describe("server-function", () => {
9898
await page.goto("http://localhost:3000/server-function-unused-trycatch");
9999
await expect(page.locator("#server-fn-test")).toContainText("false");
100100
});
101+
102+
test("should build with a server function including an unused destructured variable", async ({
103+
page,
104+
}) => {
105+
await page.goto("http://localhost:3000/server-function-unused-destructure");
106+
await expect(page.locator("#server-fn-test")).toContainText("false");
107+
});
101108
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createEffect, createSignal } from "solid-js";
2+
3+
function serverFnDestructure() {
4+
"use server";
5+
6+
const rawItems = [{ id: "", age: 42 }];
7+
const items: { age: number }[] = [];
8+
for (const { id, ...rest } of rawItems) {
9+
items.push(rest);
10+
}
11+
12+
return false;
13+
}
14+
15+
export default function App() {
16+
const [output, setOutput] = createSignal<boolean>();
17+
18+
createEffect(async () => {
19+
const result = await serverFnDestructure();
20+
setOutput(result);
21+
});
22+
23+
return (
24+
<main>
25+
<span id="server-fn-test">{JSON.stringify(output())}</span>
26+
</main>
27+
);
28+
}

0 commit comments

Comments
 (0)