trpc-nuxt
trpc-nuxt copied to clipboard
useAsyncQuery is not correctly typed
First of all, thanks for creating this project, its a massive joy to work with. But I've noticed a couple of bugs around useAsyncQuery:
- The options that one can pass to nuxt/useAsyncData aren't correctly typed, according to volar, theyre typed as
never
, although they should bestring[]
. Example: https://github.com/hugohabicht01/howdoyoudo/blob/master/pages/user/%5Bid%5D.vue#L14 - The data property that useAsyncQuery emits, seems to always be
Pick<RETURNTYPE, never>
(RETURNTYPE being the type that the trpc query returns). Example: https://github.com/hugohabicht01/howdoyoudo/blob/master/pages/user/%5Bid%5D.vue#L44
Looks like it has to do with this line: https://github.com/wobsoriano/trpc-nuxt/blob/master/src/runtime/client.ts#L51
Changing from
): Promise<AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, TError>> {
to
): Promise<AsyncData<ReturnType<Transform>, TError>> {
Resolves the typing error but it looks like you lose the picking helper.
Nuxt can't type array picks too. You can use the transform
option for now to get proper types:
