Open History to see the last commit
1// Type-only probe — verifies that UseChatOptions's ChatTransport XOR
2// survives DistributedOmit. These assertions exercise type errors at
3// compile time; the test file body is empty.
4import { describe, it, expectTypeOf } from 'vitest'
5import type { ChatFetcher, ConnectionAdapter } from '@tanstack/ai-client'
6import type { UseChatOptions } from '../src/types'
7
8describe('UseChatOptions XOR', () => {
9 it('rejects neither / both, accepts exactly one', () => {
10 // Accept connection only
11 expectTypeOf<{
12 connection: ConnectionAdapter
13 threadId: string
14 }>().toMatchTypeOf<UseChatOptions>()
15 // Accept fetcher only
16 expectTypeOf<{
17 fetcher: ChatFetcher
18 threadId: string
19 }>().toMatchTypeOf<UseChatOptions>()
20 // Reject empty
21 expectTypeOf<{}>().not.toMatchTypeOf<UseChatOptions>()
22 // Reject both
23 expectTypeOf<{
24 connection: ConnectionAdapter
25 fetcher: ChatFetcher
26 }>().not.toMatchTypeOf<UseChatOptions>()
27 })
28})