Download react-query/packages/solid-query/src/__tests__/useQueryOptions.test-d.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/solid-query/src/__tests__/useQueryOptions.test-d.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/solid-query/src/__tests__/useQueryOptions.test-d.tsx
-
curl -L -o useQueryOptions.test-d.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/solid-query/src/__tests__/useQueryOptions.test-d.tsx
2.06 kB
| import { describe, expectTypeOf, it } from 'vitest' | |
| import { dataTagSymbol } from '@tanstack/query-core' | |
| import { useInfiniteQuery } from '../useInfiniteQuery' | |
| import { infiniteQueryOptions } from '../infiniteQueryOptions' | |
| import type { InfiniteData } from '@tanstack/query-core' | |
| import type { | |
| DefinedInitialDataInfiniteOptions, | |
| UndefinedInitialDataInfiniteOptions, | |
| } from '../infiniteQueryOptions' | |
| describe('infiniteQueryOptions', () => { | |
| it('should infer defined types', () => { | |
| const options = infiniteQueryOptions({ | |
| getNextPageParam: () => 10, | |
| queryKey: ['key'], | |
| queryFn: () => ({ wow: true }), | |
| initialData: { | |
| pageParams: [undefined], | |
| pages: [{ wow: true }], | |
| }, | |
| initialPageParam: 0, | |
| }) | |
| expectTypeOf(useInfiniteQuery(() => options).data).toEqualTypeOf< | |
| InfiniteData<{ wow: boolean }, unknown> | |
| >() | |
| expectTypeOf(options).toMatchTypeOf< | |
| ReturnType< | |
| DefinedInitialDataInfiniteOptions< | |
| { wow: boolean }, | |
| Error, | |
| InfiniteData<{ wow: boolean }, unknown>, | |
| Array<string>, | |
| number | undefined | |
| > | |
| > | |
| >() | |
| expectTypeOf(options.queryKey[dataTagSymbol]).toEqualTypeOf< | |
| InfiniteData<{ wow: boolean }> | |
| >() | |
| }) | |
| it('should work without defined types', () => { | |
| const options = infiniteQueryOptions({ | |
| getNextPageParam: () => undefined, | |
| queryKey: ['key'], | |
| queryFn: () => ({ wow: true }), | |
| initialPageParam: 0, | |
| }) | |
| expectTypeOf(() => useInfiniteQuery(() => options).data).toEqualTypeOf< | |
| () => InfiniteData<{ wow: boolean }, unknown> | undefined | |
| >() | |
| expectTypeOf(options).toMatchTypeOf< | |
| ReturnType< | |
| UndefinedInitialDataInfiniteOptions< | |
| { wow: boolean }, | |
| Error, | |
| InfiniteData<{ wow: boolean }, unknown>, | |
| Array<string>, | |
| number | |
| > | |
| > | |
| >() | |
| expectTypeOf(options.queryKey[dataTagSymbol]).toEqualTypeOf< | |
| InfiniteData<{ | |
| wow: boolean | |
| }> | |
| >() | |
| }) | |
| }) | |