refactor: type helpers

This commit is contained in:
Robert Soriano
2022-05-20 11:22:19 -07:00
parent eb1bd0c700
commit f9b0aa002e
4 changed files with 10 additions and 10 deletions

View File

@@ -10,11 +10,12 @@ import type { TRPCClientErrorLike } from '@trpc/client'
import { objectHash } from 'ohash'
import { useAsyncData, useState } from '#app'
import { useClient } from '#build/trpc-client'
// @ts-expect-error: Resolved by Nuxt
import type { router } from '~/server/trpc'
type AppRouter = typeof router
type inferProcedures<
export type inferProcedures<
TObj extends ProcedureRecord<any, any, any, any, any, any>,
> = {
[TPath in keyof TObj]: {
@@ -23,10 +24,10 @@ type inferProcedures<
};
}
type TQueries = AppRouter['_def']['queries']
type TError = TRPCClientErrorLike<AppRouter>
export type TQueries = AppRouter['_def']['queries']
export type TError = TRPCClientErrorLike<AppRouter>
type TQueryValues = inferProcedures<AppRouter['_def']['queries']>
export type TQueryValues = inferProcedures<AppRouter['_def']['queries']>
export async function useAsyncQuery<
TPath extends keyof TQueryValues & string,

View File

@@ -1,10 +1,8 @@
import type { inferProcedureInput, inferProcedureOutput, inferSubscriptionOutput } from '@trpc/server'
// @ts-expect-error: Resolved by Nuxt
import type { router } from '~/server/trpc'
/**
* The main router type
*/
export type AppRouter = typeof router
type AppRouter = typeof router
/**
* Enum containing all api query paths