Skip to content

Codemode documented as supporting Typescript, does not seem to #959

@rwdaigle

Description

@rwdaigle

Summary

Codemode public docs claim Typescript is supported. However, attempts to execute TS seem to fail due to TS-specific syntax errors.

Image

Workaround

Prompting to only use Javascript is successful.

To Reproduce

  1. Create an AI Agent using the Agents SDK and give it the codemode tool
  2. Give a specific prompt asking to execute Typescript
  3. Observe codemode syntax errors

Example

execute a basic Typescript function and show me any errors

✗ code: code
✗ code: code

I attempted to execute a TypeScript function, but it appears the code execution environment doesn't support TypeScript syntax (it likely only runs JavaScript). Here's what happened and what I can show you instead:

The error you'll see with TypeScript code execution:

SyntaxError: Unexpected token ':'

Here's a JavaScript equivalent that would work:

function add(a, b) {
  return a + b;
}

function greet(name) {
  return `Hello, ${name}!`;
}

// This line would cause an error if we had TypeScript type checking
const greeting = greet(123); // We'd get a type mismatch warning in TypeScript

// Works fine
const sum = add(5, 3);
console.log(sum); // Output: 8

Versions

Package Specifier Installed
@cloudflare/ai-chat latest 0.1.3
@cloudflare/codemode 0.1.0 0.1.0
agents latest 0.5.1

Context

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