Skip to content

fix: typing generated for options parameter in the hooks method #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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