Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Text adapters fail chat()'s adapter constraint under exactOptionalPropertyTypes (midConversationChannels)

未关闭
#1,777 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@tombeckenham 已经在做这个了。

开始于 2026年10月14日。

评估

这个 Issue 还没有评估数据。

描述

waiting-on: maintainer
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:

  1. Install @tanstack/[email protected] and [email protected].
  2. Typecheck repro.ts with the tsconfig.json below.
{ "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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/ai 的其他 Issue

查看 TanStack/ai 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。