Workflow tool: script parse errors always blame "TypeScript syntax" even for plain-JS errors (misleading)
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(inlinescript) - Model: Claude Opus 4.8
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗