Skip to content

Port TS#61534: correct source location when react-jsx and whitespace before jsx#2807

Merged
jakebailey merged 3 commits intomainfrom
copilot/port-correct-source-location
Feb 17, 2026
Merged

Port TS#61534: correct source location when react-jsx and whitespace before jsx#2807
jakebailey merged 3 commits intomainfrom
copilot/port-correct-source-location

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

JSX source location metadata (columnNumber in react-jsxdev output) was computed from node.Pos(), which includes leading trivia (whitespace). This produced incorrect column numbers when whitespace preceded JSX elements.

Ports microsoft/TypeScript#61534.

  • Skip leading trivia via scanner.SkipTrivia() before using the position as the location in visitJsxElement, visitJsxSelfClosingElement, and visitJsxFragment
location := element.AsNode()
location.Loc = core.NewTextRange(scanner.SkipTrivia(tx.currentSourceFile.Text(), element.Pos()), element.End())
return tagTransform(tx, element.OpeningElement, element.Children, location)

Baseline diffs confirm column numbers now match TypeScript output across all affected react-jsxdev test cases.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

… whitespace before jsx

Skip leading trivia when computing the location range for JSX elements,
self-closing elements, and fragments in the JSX transformer. This ensures
correct columnNumber values in react-jsxdev source location metadata.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Port correct source location for react-jsx handling Port TS#61534: correct source location when react-jsx and whitespace before jsx Feb 17, 2026
Copilot AI requested a review from jakebailey February 17, 2026 19:22
@jakebailey jakebailey marked this pull request as ready for review February 17, 2026 19:47
Copilot AI review requested due to automatic review settings February 17, 2026 19:47
Copy link
Contributor

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

This pull request ports TypeScript PR #61534 to fix incorrect JSX source location metadata (specifically columnNumber in react-jsxdev output) that occurred when whitespace preceded JSX elements. The fix ensures that column numbers now point to the actual start of the JSX tag rather than including leading whitespace.

Changes:

  • Modified JSX transformation to skip leading trivia when computing source locations for react-jsxdev mode
  • Updated all affected test baselines to match TypeScript's correct output

Reviewed changes

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

Show a summary per file
File Description
internal/transformers/jsxtransforms/jsx.go Added trivia skipping logic to visitJsxElement, visitJsxSelfClosingElement, and visitJsxFragment functions to compute correct source positions
testdata/baselines/reference/submodule/conformance/*.diff Reduced diff files showing convergence with TypeScript reference output
testdata/baselines/reference/submodule/conformance/*.js Updated baselines with corrected column numbers matching TypeScript
testdata/baselines/reference/submodule/compiler/*.diff Reduced diff files showing convergence with TypeScript reference output
testdata/baselines/reference/submodule/compiler/*.js Updated baselines with corrected column numbers matching TypeScript

@jakebailey jakebailey marked this pull request as draft February 17, 2026 22:10
@jakebailey jakebailey marked this pull request as ready for review February 17, 2026 22:57
@jakebailey jakebailey added this pull request to the merge queue Feb 17, 2026
Merged via the queue into main with commit d0c8841 Feb 17, 2026
20 checks passed
@jakebailey jakebailey deleted the copilot/port-correct-source-location branch February 17, 2026 23:13
Copilot AI added a commit that referenced this pull request Feb 25, 2026
…before jsx (#2807)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
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.

4 participants