trpc-nuxt icon indicating copy to clipboard operation
trpc-nuxt copied to clipboard

useAsyncQuery is not correctly typed

Open hugohabicht01 opened this issue 2 years ago • 2 comments

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:

  1. The options that one can pass to nuxt/useAsyncData aren't correctly typed, according to volar, theyre typed as never, although they should be string[]. Example: https://github.com/hugohabicht01/howdoyoudo/blob/master/pages/user/%5Bid%5D.vue#L14
  2. 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

hugohabicht01 avatar Aug 14 '22 13:08 hugohabicht01

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.

birdlavv avatar Oct 01 '22 15:10 birdlavv

Nuxt can't type array picks too. You can use the transform option for now to get proper types:

Screen Shot 2022-10-06 at 5 16 50 PM

wobsoriano avatar Oct 07 '22 00:10 wobsoriano