Skip to content

Commit

Permalink
fix: typing generated for options parameter in the hooks method (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbozzay authored Jan 12, 2024
1 parent 52c7d01 commit acb23d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/plugins/tanstack-query/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ function makeBaseImports(target: TargetFramework, version: TanStackVersion) {
case 'svelte':
return [
`import { derived } from 'svelte/store';`,
`import type { MutationOptions, QueryOptions, CreateInfiniteQueryOptions } from '@tanstack/svelte-query';`,
`import type { MutationOptions, CreateQueryOptions, CreateInfiniteQueryOptions } from '@tanstack/svelte-query';`,
...(version === 'v5'
? [`import type { InfiniteData, StoreOrVal } from '@tanstack/svelte-query';`]
: []),
Expand Down Expand Up @@ -597,8 +597,8 @@ function makeQueryOptions(target: string, returnType: string, infinite: boolean,
? `Omit<CreateInfiniteQueryOptions<${returnType}>, 'queryKey'>`
: `StoreOrVal<Omit<CreateInfiniteQueryOptions<${returnType}, unknown, InfiniteData<${returnType}>>, 'queryKey'>>`
: version === 'v4'
? `Omit<QueryOptions<${returnType}>, 'queryKey'>`
: `StoreOrVal<Omit<QueryOptions<${returnType}>, 'queryKey'>>`;
? `Omit<CreateQueryOptions<${returnType}>, 'queryKey'>`
: `StoreOrVal<Omit<CreateQueryOptions<${returnType}>, 'queryKey'>>`;
default:
throw new PluginError(name, `Unsupported target: ${target}`);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/tanstack-query/src/runtime-v5/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
type InfiniteData,
type MutationOptions,
type StoreOrVal,
type CreateQueryOptions,
} from '@tanstack/svelte-query-v5';
import { QueryOptions } from '@tanstack/vue-query';
import { ModelMeta } from '@zenstackhq/runtime/cross';
import { getContext, setContext } from 'svelte';
import { Readable, derived } from 'svelte/store';
Expand Down Expand Up @@ -62,7 +62,7 @@ export function useModelQuery<R>(
model: string,
url: string,
args?: unknown,
options?: StoreOrVal<Omit<QueryOptions<R>, 'queryKey'>>,
options?: StoreOrVal<Omit<CreateQueryOptions<R>, 'queryKey'>>,
fetch?: FetchFn,
optimisticUpdate = false
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/tanstack-query/src/runtime/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useQueryClient,
type CreateInfiniteQueryOptions,
type MutationOptions,
type QueryOptions,
type CreateQueryOptions,
} from '@tanstack/svelte-query';
import { ModelMeta } from '@zenstackhq/runtime/cross';
import { getContext, setContext } from 'svelte';
Expand Down Expand Up @@ -59,7 +59,7 @@ export function useModelQuery<R>(
model: string,
url: string,
args?: unknown,
options?: Omit<QueryOptions<R>, 'queryKey'>,
options?: Omit<CreateQueryOptions<R>, 'queryKey'>,
fetch?: FetchFn,
optimisticUpdate = false
) {
Expand Down

0 comments on commit acb23d1

Please sign in to comment.