Text adapters fail chat()'s adapter constraint under exactOptionalPropertyTypes (midConversationChannels)
维护者通常 1 天内回复
@tombeckenham 已经在做这个了。
开始于 2026年10月14日。
评估
这个 Issue 还没有评估数据。
描述
TanStack AI version
@tanstack/ai 0.69.0 (regression from 0.68.0)
Framework/Library version
TypeScript 6.0.3 with strict and exactOptionalPropertyTypes. Framework-independent.
Describe the bug and the steps to reproduce it
Under exactOptionalPropertyTypes, no text adapter class satisfies chat()'s AnyTextAdapter constraint in 0.69.0, including the built-in fakeText() and the Anthropic and OpenAI adapters. This is the same defect #1702 reported for inputModalities, which #1707 fixed. The new midConversationChannels field from #1697 reintroduces it.
In packages/ai/src/activities/chat/adapter.ts, the TextAdapter interface declares the field without | undefined:
readonly midConversationChannels?: MidConversationChannels
but BaseTextAdapter declares it with | undefined:
readonly midConversationChannels?: MidConversationChannels | undefined = undefined
so every subclass is unassignable to the interface. Adding | undefined to the interface field, as #1707 did for inputModalities, should fix it.
Steps:
- Install
@tanstack/[email protected]and[email protected]. - Typecheck
repro.tswith thetsconfig.jsonbelow.
{ "compilerOptions": { "strict": true, "exactOptionalPropertyTypes": true, "module": "nodenext", "target": "es2022", "noEmit": true, "skipLibCheck": true }, "files": ["repro.ts"] }
import { chat } from "@tanstack/ai"
import { fakeText } from "@tanstack/ai/testing"
chat({ adapter: fakeText(), messages: [{ role: "user", content: "Hi" }] })
Result with 0.69.0:
repro.ts(4,8): error TS2375: Type 'FakeTextAdapter<"fake-model", readonly ("text" | "image" | "audio" | "video" | "document")[]>' is not assignable to type 'AnyTextAdapter' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'midConversationChannels' are incompatible.
Type 'MidConversationChannels | undefined' is not assignable to type 'MidConversationChannels'.
Type 'undefined' is not assignable to type 'MidConversationChannels'.
The same files typecheck without errors against 0.68.0.
As a workaround, we set an explicit all-off value, { tools: false, systemPrompts: false }, which chat() treats the same as an absent value.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
The three files above are the complete reproduction.
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
No, because I don't have time to work on this right now
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- 主要语言
- TypeScript
- 星标
- 3.2k
- 派生
- 361
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 252
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/ai 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 32/100
维护者通常 1 天内回复
-
Responses replay puts assistant text between function_call and function_call_output可能已有人在做 @tombeckenham 于 1 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
move to modelschemas可能已有人在做 @jherr 于 1 天前认领。 未关闭has-pr waiting-on: maintainer
维护者通常 1 天内回复
-
chat(): sign the state of a suspended run so a resume without persistence cannot change it可能已有人在做 @AlemTuzlak 于 2 天前认领。 未关闭waiting-on: maintainer
TanStack/ai#1740 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
@tanstack/ai-anthropic: a stream that fails after message_start loses the call's input usage可能已有人在做 @AlemTuzlak 于 3 天前认领。 未关闭waiting-on: maintainer
TanStack/ai#1735 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
area:ui effort:S enhancement priority:P2
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
QuantumNous/new-api#7839 ·
维护者通常 1 天内回复
-
good first issue maintenance
难度 2/5 1-3 小时 新手友好度 62/100
dark-princezz/stellar-hooks#1010 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
interledger/rhyza#352 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复