Skip to content

TS Error due to no overlap with AI SDK v5 states #247

@FelixTraxler

Description

@FelixTraxler

AI Elements uses the types from ToolUIPart["state"] from the AI SDK and checks against types added in AI SDK v6. Using the recommended install path described on the AI SDK docs leads to build errors due to strict type checking

Steps to reproduce:

  1. Set up Next App Router with AI SDK
pnpm create next-app@latest my-ai-app
cd my-ai-app
pnpm add ai @ai-sdk/react zod
  1. (Sanity Check) Check if project builds
pnpm run build
  1. Add AI Elements
npx ai-elements@latest
  1. Check if project builds
pnpm run build

> [email protected] build /[...]/my-ai-app
> next build

   ▲ Next.js 16.0.3 (Turbopack)

   Creating an optimized production build ...
 ✓ Compiled successfully in 662.5ms
   Running TypeScript  .Failed to compile.

./components/ai-elements/confirmation.tsx:100:7
Type error: This comparison appears to be unintentional because the types '"input-streaming" | "input-available" | "output-available" | "output-error"' and '"approval-requested"' have no overlap.

   98 |
   99 |   // Only show when approval is requested
> 100 |   if (state !== "approval-requested") {
      |       ^
  101 |     return null;
  102 |   }
  103 |
Next.js build worker exited with code: 1 and signal: null
 ELIFECYCLE  Command failed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions