Skip to content

fix(chat): correctly type thread and channel interface#242

Open
rayhanadev wants to merge 2 commits intovercel:mainfrom
rayhanadev:ray/fix-thread-type
Open

fix(chat): correctly type thread and channel interface#242
rayhanadev wants to merge 2 commits intovercel:mainfrom
rayhanadev:ray/fix-thread-type

Conversation

@rayhanadev
Copy link

Why

The Thread and Channel interfaces in types.ts are missing toJSON() method declarations, even though the implementations (ThreadImpl, ChannelImpl) both implement it. This causes TypeScript errors when code typed against the public interfaces calls thread.toJSON() or channel.toJSON().

Closes #241

What changed?

  • Added toJSON(): SerializedThread to the Thread interface
  • Added toJSON(): SerializedChannel to the Channel interface
  • Added type-only imports for SerializedThread and SerializedChannel in types.ts

Test plan

  • pnpm validate passes (typecheck, lint, build, tests across all packages)
  • thread.toJSON() now type-checks correctly against the Thread interface in sample code
  • same w/ Channel

Copilot AI review requested due to automatic review settings March 14, 2026 20:08
@vercel
Copy link
Contributor

vercel bot commented Mar 14, 2026

@rayhanadev is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a TypeScript typing gap in the chat SDK by aligning the public Thread and Channel interfaces with their concrete implementations, which already support serialization via toJSON().

Changes:

  • Added toJSON(): SerializedChannel to the Channel interface.
  • Added toJSON(): SerializedThread to the Thread interface.
  • Added type-only imports for SerializedChannel and SerializedThread in types.ts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thread interface is missing toJSON() method

2 participants