mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-19 14:31:45 +01:00
refactor: type helpers
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user