Skip to content
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

fix: don't override default generic types in useObservableQuery #182

Merged
merged 2 commits into from
Aug 21, 2023

Conversation

bram209
Copy link
Contributor

@bram209 bram209 commented Aug 21, 2023

Issue is that generic args are inferred and all generic arguments are passed to UseBaseQueryOptions explicitly.

export interface UseBaseQueryOptions<
  TQueryFnData = unknown,
  TError = unknown,
  TData = TQueryFnData,
  TQueryData = TQueryFnData,
  TQueryKey extends QueryKey = QueryKey
> extends ...

Causing the defaults to be overidden with unknown

In a simple case like:

        const query$ = useObservableQuery({
            queryKey: ['test'],
            queryFn: () => Promise.resolve({ a: 1, b: 2 }),
        });

it would not be able to infer TData, therefore the resulting type will be: ObservableObject<UseBaseQueryResult<unknown, unknown>

@jmeistrich jmeistrich merged commit e314319 into LegendApp:main Aug 21, 2023
3 checks passed
@jmeistrich
Copy link
Contributor

Thanks @bram209! We don't actually use useObservableQuery ourselves so I'm trusting that you're correct :). Released in version 1.10.2.

@bram209 bram209 deleted the fix/observable-query-types branch August 23, 2023 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants