Skip to content

Conversation

ahejlsberg
Copy link
Member

Fixes #1749.

@Copilot Copilot AI review requested due to automatic review settings September 24, 2025 17:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes speculative parsing in JavaScript files by properly handling JavaScript-specific diagnostics during parser state mark/rewind operations. When the parser marks a state for potential backtracking and later rewinds, it now correctly restores both regular diagnostics and JavaScript-specific diagnostics to their previous state.

  • Added jsDiagnosticsLen field to ParserState to track JavaScript diagnostic count
  • Modified mark() method to capture current JavaScript diagnostics length
  • Updated rewind() method to truncate jsDiagnostics array to the saved length

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/parser/parser.go Adds JavaScript diagnostics tracking to parser state mark/rewind mechanism
testdata/tests/cases/compiler/jsSpeculativeParsingError.ts Test case demonstrating the fix for JavaScript speculative parsing errors
testdata/baselines/reference/compiler/jsSpeculativeParsingError.types Expected type output baseline for the test case
testdata/baselines/reference/compiler/jsSpeculativeParsingError.symbols Expected symbol output baseline for the test case

@jakebailey jakebailey added this pull request to the merge queue Sep 24, 2025
Merged via the queue into main with commit 0b9f3e7 Sep 24, 2025
22 checks passed
@jakebailey jakebailey deleted the fix-1749 branch September 24, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Erroneous "The '?' modifier can only be used in TypeScript files"

2 participants