From addfdc8f5dd4125ecc36eb24083eba8d8e14240b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 7 Sep 2026 16:15:40 +0000 Subject: [PATCH 1/2] refactor(plugin-chatbot): drop the inert blanket cast on the useChat options object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `useChat({...} as any)` widened the whole options argument to `any`, switching off checking of `transport`, `onError` and excess properties, and blocking inference of `UI_MESSAGE`. Measured: with the nested `(aiInitialMessages as any)` in place, the outer cast hides nothing — both type-check projects stay at exit 0 with zero diagnostics without it — and the resolved instantiation is unchanged, `UseChatHelpers>` either way, because `transport` is the only inference source and it is already pinned to that type. This narrows the suppression rather than eliminating it: removing BOTH casts is red (TS2322, `Record` is not a `UIMessagePart`), so the nested cast is the live one. A comment now records that, so the next reader does not delete it blind or re-widen the call. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S --- packages/plugin-chatbot/src/useObjectChat.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-chatbot/src/useObjectChat.ts b/packages/plugin-chatbot/src/useObjectChat.ts index ff06f46f94..0c3c0da625 100644 --- a/packages/plugin-chatbot/src/useObjectChat.ts +++ b/packages/plugin-chatbot/src/useObjectChat.ts @@ -701,6 +701,14 @@ export function useObjectChat(options: UseObjectChatOptions = {}): UseObjectChat const chatRef = useRef(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[]`, 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) => { @@ -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 From 4a134d170945ab95d1a581e97242dfdfa978ad29 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 7 Sep 2026 16:30:42 +0000 Subject: [PATCH 2/2] chore(changeset): declare the useChat options-cast removal as releasing nothing Empty frontmatter, the gate's documented exemption. Argued from measurement: building @object-ui/plugin-chatbot from this branch and from the merge-base produced a byte-identical dist across all 34 published artifacts, and that comparison was proved live by a control mutation to an emitted string literal. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S --- .changeset/issue-8378-usechat-options-cast.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/issue-8378-usechat-options-cast.md diff --git a/.changeset/issue-8378-usechat-options-cast.md b/.changeset/issue-8378-usechat-options-cast.md new file mode 100644 index 0000000000..5b130b58a4 --- /dev/null +++ b/.changeset/issue-8378-usechat-options-cast.md @@ -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.