From 97d9b3ddf85bd90cc66ae77fe3fd7bc1aa2e9889 Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Sun, 30 Oct 2022 12:57:57 -0700 Subject: [PATCH] import useAsyncData and useState from #app --- src/client/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/index.ts b/src/client/index.ts index 570a7b2..ec88e7d 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -6,6 +6,8 @@ import type { import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared' import { hash } from 'ohash' import type { DecoratedProcedureRecord } from './types' +// @ts-ignore: nuxt internal +import { useAsyncData, useState } from '#app' /** * Calculates the key used for `useAsyncData` call @@ -27,7 +29,7 @@ export function createNuxtProxyDecoration(name: strin const pathCopy = [name, ...opts.path] // The last arg is for instance `.mutate` or `.query()` - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const lastArg = pathCopy.pop()! const path = pathCopy.join('.') @@ -44,9 +46,7 @@ export function createNuxtProxyDecoration(name: strin * Custom useAsyncData to add server error to client */ async function useAsyncDataWithError(queryKey: string, cb: any, asyncDataOptions: any) { - // @ts-ignore: nuxt internal const serverError = useState(`error-${queryKey}`, () => null) - // @ts-ignore: nuxt internal const { error, data, ...rest } = await useAsyncData(queryKey, cb, asyncDataOptions) if (error.value && !serverError.value)