claude-code - 💡(How to fix) Fix Workflow tool: script parse errors always blame "TypeScript syntax" even for plain-JS errors (misleading)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When a Workflow script fails to parse, the error message unconditionally attributes the failure to TypeScript syntax, regardless of the actual cause. This is misleading and sends you debugging the wrong thing.

Error Message

Error: Invalid workflow script: Script parse error: Unexpected token (81:161). Workflow scripts must be plain JavaScript — TypeScript syntax (type annotations like : string[], interfaces, generics) fails to parse.

Root Cause

When a Workflow script fails to parse, the error message unconditionally attributes the failure to TypeScript syntax, regardless of the actual cause. This is misleading and sends you debugging the wrong thing.

Code Example

Error: Invalid workflow script: Script parse error: Unexpected token (81:161). Workflow scripts must be plain JavaScriptTypeScript syntax (type annotations like `: string[]`, interfaces, generics) fails to parse.

---

export const meta = { name: 'x', description: 'y' }
const s = 'this string ends early\\' and the rest is garbage'
log(s)
RAW_BUFFERClick to expand / collapse

Summary

When a Workflow script fails to parse, the error message unconditionally attributes the failure to TypeScript syntax, regardless of the actual cause. This is misleading and sends you debugging the wrong thing.

What happened

My workflow script contained a single-quoted JS string with an over-escaped apostrophe — '...couldn\\'t-measure...'. In JavaScript that is escaped-backslash followed by a string-terminating quote, so the rest of the line becomes stray tokens. A pure-JavaScript quoting bug — no TypeScript involved.

The tool returned:

Error: Invalid workflow script: Script parse error: Unexpected token (81:161). Workflow scripts must be plain JavaScript — TypeScript syntax (type annotations like `: string[]`, interfaces, generics) fails to parse.

The Unexpected token (81:161) part is correct and useful. The appended sentence — "TypeScript syntax (type annotations like : string[], interfaces, generics) fails to parse" — is factually wrong for this error and led me (and would lead anyone) to scan for type annotations that aren't there.

Expected

The error should report the actual parser diagnostic (token + location, ideally the offending source line/caret), and only mention TypeScript when the parse error is plausibly TS-related (e.g. the parser actually choked on a type-annotation token). The unconditional "this is TypeScript" suffix should not be appended to every parse failure.

Minimal repro

A workflow script containing a single-quoted string with a terminating escape, e.g.:

export const meta = { name: 'x', description: 'y' }
const s = 'this string ends early\\' and the rest is garbage'
log(s)

→ "Unexpected token … Workflow scripts must be plain JavaScript — TypeScript syntax …" (misattributed).

Impact

Low severity but real friction: the wrong root-cause hint cost debugging time on an otherwise one-character fix. Suggest: surface the raw parser message + a source excerpt with a caret, and gate the TypeScript hint on the error actually involving a type-syntax token.

Environment

  • Claude Code version: 2.1.156 (Claude Code)
  • Tool: Workflow (inline script)
  • Model: Claude Opus 4.8

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING