Skip to content

tool definition does not infer types in .server and .client #235

@satvikreddy

Description

@satvikreddy

TanStack AI version

v0.2.2

Framework/Library version

v19.2.3

Describe the bug and the steps to reproduce it

Tanstack ai docs mention that tool definition is fully typesafe.

But the client function shows input as unknown.

Image

Minimal repro:

import { toolDefinition } from '@tanstack/ai'
import z from 'zod'

export const saveToLocalStorageDef = toolDefinition({
  name: 'save_to_local_storage',
  description: 'Save data to browser local storage',
  inputSchema: z.object({
    key: z.string().describe('Storage key'),
    value: z.string().describe('Value to store'),
  }),
  outputSchema: z.object({
    saved: z.boolean(),
  }),
})

const saveToLocalStorage = saveToLocalStorageDef.client((input) => {
  localStorage.setItem(input.key, input.value)
  return { saved: true }
})

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

None

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

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