You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
887 B
20 lines
887 B
import { describe, expectTypeOf, it } from 'vitest'
|
|
import type { TRPCClient } from '@trpc/client'
|
|
import type { AppRouter } from '../../src/main/trpc/app-router'
|
|
import type { Note, Settings } from '@template/contracts'
|
|
|
|
type Client = TRPCClient<AppRouter>
|
|
describe('tRPC client inference', () => {
|
|
it('preserves per-procedure input and output types', () => {
|
|
expectTypeOf<ReturnType<Client['notes']['list']['query']>>().toEqualTypeOf<Promise<Note[]>>()
|
|
expectTypeOf<ReturnType<Client['settings']['get']['query']>>().toEqualTypeOf<
|
|
Promise<Settings>
|
|
>()
|
|
expectTypeOf<Parameters<Client['notes']['add']['mutate']>[0]>().toEqualTypeOf<string>()
|
|
expectTypeOf<Parameters<Client['files']['write']['mutate']>[0]>().toEqualTypeOf<{
|
|
token: string
|
|
text: string
|
|
}>()
|
|
expectTypeOf<Client['settings']['changed']>().toHaveProperty('subscribe')
|
|
})
|
|
})
|
|
|