claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Missing Type Definition in Official TS SDK

Open brian-lou opened this issue 8 months ago • 1 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 1.0.21
  • Operating System: macOS 15.5
  • Terminal: zsh

Bug Description

The Typescript SDK: @anthropic-ai/claude-code does not export types

Steps to Reproduce

Try to use:

import { query, type SDKMessage } from '@anthropic-ai/claude-code';

Expected Behavior

No errors

Actual Behavior

Typescript is unable to resolve the correct type and errors with:

Could not find a declaration file for module '@anthropic-ai/claude-code'. '/Users/brian/gt/gt-libraries/node_modules/@anthropic-ai/claude-code/sdk.mjs' implicitly has an 'any' type.

Additional Context

Adding "types": "sdk.d.ts", to the package.json fixes the issue

brian-lou avatar Jun 12 '25 21:06 brian-lou

Fix incoming!

bcherny avatar Jun 13 '25 00:06 bcherny

I think this is now working but I'm noticing references to the SDK are not resolving properly, meaning Message is typed as any

Image

maschwenk avatar Jul 02 '25 13:07 maschwenk

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Oct 10 '25 10:10 github-actions[bot]

Hey this is still an issue. Any updates on this?

ali-nr avatar Nov 16 '25 00:11 ali-nr

Ok for whoever comes here, u need to now use the lib @anthropic-ai/claude-agent-sdk. They have renamed it. Install this one and you are good to go 😄

ali-nr avatar Nov 16 '25 08:11 ali-nr

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] avatar Dec 16 '25 10:12 github-actions[bot]