Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,777 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@tombeckenham đang làm issue này rồi.

Từ ngày 14/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
3.2k
Fork
361
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
252

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/ai

Tất cả issue của TanStack/ai

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.