Skip to content

fix(formatting): recover from token spans outside property children#63629

Open
ahfoysal wants to merge 1 commit into
microsoft:mainfrom
ahfoysal:fix/63598-formatter-child-token
Open

fix(formatting): recover from token spans outside property children#63629
ahfoysal wants to merge 1 commit into
microsoft:mainfrom
ahfoysal:fix/63598-formatter-child-token

Conversation

@ahfoysal

@ahfoysal ahfoysal commented Jul 7, 2026

Copy link
Copy Markdown

Summary

  • Fix formatting recursion guard in processChildNode to handle scanner tokens that overrun the current child node boundary in recovery scenarios.
  • Add regression fourslash test for the invalid type-literal property syntax (type X = { prop: = \${abc}`xyz }) that triggered Debug Failure. False expression: Token end is child end`.

Validation

  • npx hereby runtests --tests formattingTokenEndChildEnd --light=false
    • ✅ 1 passing (fourslash regression)

Fixes #63598.

Handle recovery cases where a token ends after the current child while formatting invalid syntax, to avoid entering invalid scanner state.

Fixes microsoft#63598.
Copilot AI review requested due to automatic review settings July 7, 2026 08:38
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Jul 7, 2026
@ahfoysal

ahfoysal commented Jul 7, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a formatter debug assertion in processChildNode by improving the scanner/AST synchronization logic when recovery parsing produces tokens whose scanned spans exceed the current child node’s end boundary. Adds a fourslash regression test reproducing the invalid type-literal property syntax from #63598.

Changes:

  • Update processChildNode’s pre-child token consumption loop to rewind the formatting scanner when the current scanned token overruns the child’s end.
  • Add a fourslash regression test that formats an invalid type-literal property and asserts formatting completes without crashing.

Reviewed changes

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

File Description
tests/cases/fourslash/formattingTokenEndChildEnd.ts New regression test covering the recovery scenario that previously triggered the formatter assertion.
src/services/formatting/formatting.ts Adjusts scanner rewind conditions to handle tokens spanning beyond a child node in recovery parsing, preventing Debug.assert(tokenInfo.token.end === child.end) failures.

@MartinJohns

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

"Token end is child end" when '= ${id}id' is used in a property annotation

3 participants