deno.land / x / jotai@v1.8.4 / tests / utils / waitForAll.types.test.tsx

waitForAll.types.test.tsx
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { expectType } from 'ts-expect'import { atom, useAtomValue } from 'jotai'import { waitForAll } from 'jotai/utils'
it('waitForAll() should return the correct types', () => { function Component() { const numberAtom = atom(async () => 0) const stringAtom = atom(async () => '')
const [number, string] = useAtomValue(waitForAll([numberAtom, stringAtom])) expectType<number>(number) expectType<string>(string)
const { numberAtom: number2, stringAtom: string2 } = useAtomValue( waitForAll({ numberAtom, stringAtom }) ) expectType<number>(number2) expectType<string>(string2) } Component})
jotai

Version Info

Tagged at
a year ago