Skip to content

[Types] Error: Property 'text' does not exist on type 'ContentBlock'. #432

@davidstackio

Description

@davidstackio

After updating to v0.22.0 from v0.20.9, I'm getting a type error on the last line of this block (text = msg.content[0].text;):

const msg = await anthropic.messages.create({
      model: "claude-3-opus-20240229",
      max_tokens: maxOutputTokens,
      temperature: 0.9,
      messages: [
        {
          role: "user",
          content: [
            {
              type: "text",
              text: prompt,
            },
          ],
        },
      ],
    });
    text = msg.content[0].text;

The type error is:

Property 'text' does not exist on type 'ContentBlock'.
  Property 'text' does not exist on type 'ToolUseBlock'.ts(2339)

When logging the message content, it does not appear to have changed, so I'm guessing this is just a type bug that needs fixed. My code works as expected when adding the // @ts-ignore comment above the problem line, which is my current workaround.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions