Skip to content

Commit 26a6b09

Browse files
committed
chore(react-call): silence biome warnings on async mutation primitive
Two leftover warnings after the feat commit: 1. mutate.test.tsx: `type NoProps = void` was matching the lib's `Props = void` default to exercise the void-Props ergonomic form. biome's `noConfusingVoidType` doesn't know that context — same `biome-ignore` reason is already used in callable-types.test.ts. 2. createCallable/index.tsx: the `storedMutationFn!(...)` non-null assertion was correct (the early-return guard above proves it defined), but TypeScript doesn't narrow the `let` across the closure boundary. Capture into a `const fn` after the guard so the closure sees the narrowed type and no assertion is needed. No behaviour change.
1 parent 8846e66 commit 26a6b09

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

packages/react-call/src/__tests__/mutate.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ describe('CallOptions plumbing', () => {
379379
})
380380

381381
test('void Props: call(options) form (no props arg) routes options correctly', async () => {
382+
// biome-ignore lint/suspicious/noConfusingVoidType: matching the lib's `Props = void` default to exercise the void-Props ergonomic form
382383
type NoProps = void
383384
const NoPropsComp: ReactCall.UserComponent<
384385
NoProps,

packages/react-call/src/createCallable/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,16 @@ export function createCallable<
122122
return
123123
}
124124

125+
// Capture the narrowed value into a const so the closure can
126+
// call it without a non-null assertion — the early-return guard
127+
// above proved storedMutationFn is defined.
128+
const fn = storedMutationFn
125129
const mutationContext: MutationContext<Response> = {
126130
end: createEnd(promise),
127131
}
128132

129133
Promise.resolve()
130-
.then(() => storedMutationFn!(mutationContext, payload))
134+
.then(() => fn(mutationContext, payload))
131135
.catch(() => {
132136
// Swallow — the caller's own try/catch inside mutationFn handles
133137
// UI side-effects (toasts, alerts, etc.). The dialog stays open

0 commit comments

Comments
 (0)