Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/issue-8378-usechat-options-cast.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
---

Removes the inert blanket `as any` on `useChat`'s options object in
`useObjectChat` (objectui#8378). Publishes nothing: the assertion lives inside a
function body whose export already carries an explicit return-type annotation, so
it is erased at emit. Measured rather than assumed — building
`@object-ui/plugin-chatbot` from this branch and from the merge-base produced a
byte-identical `dist` across all 34 published artifacts (`.d.ts`, `.js`, `.cjs`,
`.css`), and the comparison was proved live by a control mutation to an emitted
string literal, which the same comparison reported as differing.
10 changes: 9 additions & 1 deletion packages/plugin-chatbot/src/useObjectChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,14 @@ export function useObjectChat(options: UseObjectChatOptions = {}): UseObjectChat
const chatRef = useRef<any>(null);
const chatResult = useChat({
transport,
// The `as any` here is the LIVE suppression on this call, and it is the only
// one: `aiInitialMessages` builds `parts` as `Record<string, unknown>[]`, which
// is not a `UIMessagePart` union, so dropping this cast turns the call red with
// TS2322 (measured, objectui#8378). The blanket `as any` that used to sit on the
// whole options object was removed there because it hid nothing this one does not
// already absorb — but it also switched off checking of `transport`, `onError`
// and excess properties. Fix the builder before deleting this cast; do NOT
// re-widen the call by casting the options object again.
messages: isApiMode && aiInitialMessages.length > 0 ? (aiInitialMessages as any) : undefined,
onError: isApiMode
? (err: Error) => {
Expand Down Expand Up @@ -732,7 +740,7 @@ export function useObjectChat(options: UseObjectChatOptions = {}): UseObjectChat
onError?.(err);
}
: undefined,
} as any);
});
chatRef.current = chatResult;

// ADR-0057 #8 — refresh the AI usage indicator when a turn finishes. On the
Expand Down
Loading