mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
When parsing TypeScript code with `declare global { ... }` blocks,
identifiers followed by colons (like `TIMER: NodeJS.Timeout;`) were
incorrectly treated as labeled statements instead of type annotations.
This caused the parser to push a `.label` scope during the parse pass,
but when visiting the AST later, arrow functions expected `.function_args`
scopes, resulting in a "Scope mismatch while visiting" panic.
The fix checks if we're in a TypeScript declare context before treating
an identifier followed by a colon as a labeled statement. If we are in
a declare context, we skip the type annotation and return a TypeScript
node instead of creating a label scope.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>