Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

use-chat-options-probe.test.ts

24 lines928 Bytes

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 }>().toMatchTypeOf<UseChatOptions>()
14 // Accept fetcher only
15 expectTypeOf<{ fetcher: ChatFetcher }>().toMatchTypeOf<UseChatOptions>()
16 // Reject empty
17 expectTypeOf<{}>().not.toMatchTypeOf<UseChatOptions>()
18 // Reject both
19 expectTypeOf<{
20 connection: ConnectionAdapter
21 fetcher: ChatFetcher
22 }>().not.toMatchTypeOf<UseChatOptions>()
23 })
24})