TanStackT
TanStack3mo ago
9 replies
broad-emerald

createFileRoute() and createServerFn() loader type error with Vercel AI-SDK.

I get a type error in a createFileRoute() or createServerFn() loader when returning AI SDK UIMessage types. The problem is UIMessage has unknowns deeply embedded in the type structure that can't be controlled from the outside ('dynamic-tool' message parts, in particular).

I realize this is because you don't know if "unknown" will be serializable. But in a case like this, I can't control the type, and we know it will be serializable because that's the purpose of AI-SDK's UIMessage.

What's the best way to work around this case?
Was this page helpful?