fix(store): give the fix-round-2 regression test explicit generics
The single-branch 'shared'-only action fixture failed to infer through defineStore's actions generic, typing store.increment as never and failing bun run typecheck (TS2349) even though bun test passed. Explicit type arguments fix the inference without weakening the test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c8f3ede54
commit
e09a35b4bd
1 file changed
+12
-6
@@ -9,7 +9,11 @@ import { createStoreContainer, defineStore } from "../src/index.ts";
|
||||
// action once `store-codegen.ts` stopped emitting it) and has been removed.
|
||||
// This test locks in the remaining `options.runtime` -> `"shared"` chain so a
|
||||
// future edit can't silently drop the `"shared"` fallback too.
|
||||
const OnlySharedActionStore = defineStore({
|
||||
const OnlySharedActionStore = defineStore<
|
||||
{ count: number },
|
||||
Record<string, never>,
|
||||
{ increment: (amount?: number) => void }
|
||||
>({
|
||||
name: "OnlySharedActionStore",
|
||||
kind: "global" as const,
|
||||
createSharedState: () => ({ count: 0 }),
|
||||
@@ -17,12 +21,14 @@ const OnlySharedActionStore = defineStore({
|
||||
// No "client" or "server" definition exists for this action — only
|
||||
// "shared". A server-runtime container must still resolve it via the
|
||||
// "shared" fallback.
|
||||
increment: {
|
||||
runtime: "shared" as const,
|
||||
handler: ({ state }: any, amount = 1) => {
|
||||
state.count += amount;
|
||||
increment: [
|
||||
{
|
||||
runtime: "shared" as const,
|
||||
handler: ({ state }: any, amount = 1) => {
|
||||
state.count += amount;
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user