Skip to content

Commit

Permalink
possible fix for typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Jan 14, 2025
1 parent 22cd11d commit 9043fb8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/vanilla/effect.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it, vi } from 'vitest'
import type { Atom, Getter, Setter } from 'jotai/vanilla'
import type { Atom, Getter, Setter, WritableAtom } from 'jotai/vanilla'
import { atom, createStore } from 'jotai/vanilla'

type Store = ReturnType<typeof createStore>
Expand Down Expand Up @@ -260,12 +260,15 @@ it('supports recursive setting synchronous in read', async () => {
if (!ref.isMounted) {
return
}
const recurse = ((...args) => {
const recurse = <Value, Args extends unknown[], Result>(
a: WritableAtom<Value, Args, Result>,
...args: Args
): Result => {
ref.isRecursing = true
const value = ref.set(...args)
const value = ref.set(a, ...args)
delete ref.isRecursing
return value
}) as Setter
return value as Result
}
function runEffect() {
const v = get(a)
if (v < 5) {
Expand Down

0 comments on commit 9043fb8

Please sign in to comment.