fix(agent): narrow Tool description before rendering - #456
Open
hamchowderr wants to merge 1 commit into
Open
Conversation
`Tool["description"]` from the `ai` package is
`string | ((options) => string)`, so passing it straight to JSX fails to
typecheck — a function is not a ReactNode:
Type '(options: {...}) => string' is not assignable to type 'ReactNode'
`??` only guards null/undefined, so a function description falls through
to the JSX child. Narrow on `typeof === "string"` instead, which keeps
the existing fallback for both undefined and function descriptions.
Hit this consuming the registry: `shadcn add` an item that pulls `agent`
into a project with `strict` on, and `next build` fails on this line.
Contributor
|
@hamchowderr is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Tool["description"]from theaipackage is typedstring | ((options) => string).agent.tsxrenders it directly as a JSX child:??only guardsnull/undefined, so the function case falls straight through to JSX and fails to typecheck:Repro
Install an item that pulls in
agentviashadcn addinto astrictTypeScript project and runnext build. It fails atagent.tsx:106. Reproduced on Next 16.2.6 with shadcn CLI 4.16.0.Fix
Narrow on
typeof === "string", which keeps the existing fallback and now covers the function case too:One line, no behaviour change for string descriptions.
Notes
Found while maintaining a downstream registry that vendors this element specifically to carry this patch — we'd rather drop the override and depend on upstream.