Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#1,777 コメント 0 件 リアクション 0 件 担当者 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
フォーク
365
平均マージ
1日 9時間
マージ済み PR(30日)
263

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/ai のほかの issue

TanStack/ai の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。