Skip to content

fix(core): show line, column and code frame in parse and transform errors - #850

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/diagnostic-locations
Oct 16, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/diagnostic-locations

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Closes #839

Problem

join_errors attached the source with with_source_code but formatted each diagnostic with to_string(), which prints only the message. Failed to parse and Failed to transform therefore gave no line, column or code frame:

Error: Failed to parse file:///…/main.ts: Unexpected token

Fix

Each diagnostic now renders with oxc's GraphicalReportHandler, using the colorless GraphicalTheme::none() theme:

  • Location header: path:line:column. The path is decoded from the load hook's file: URL, so sub dir/m#1.ts shows as written and stays clickable in editors and terminals.
  • Code frame: the offending lines with a caret, plus the TS error code and help when oxc provides them.
  • No wrapping: messages aren't wrapped (width usize::MAX). A long message stays on one line, so searching for it still works. The default 80-column wrap split targeting ECMAScript modules and broke an existing test.

The first line keeps its old form, Failed to parse <url>:, with the reports following it:

Error: Failed to parse file:///…/main.ts:

  x Unexpected token
   ,-[/…/main.ts:3:24]
 2 | console.log(ok);
 3 | const broken: number = ;
   :                        ^
   `----
Error: Failed to transform file:///…/t1.mts:

  ! TS(1203): Export assignment cannot be used when targeting ECMAScript modules.
   ,-[/…/t1.mts:1:1]
 1 | export = 1;
   : ^^^^^^^^^^^
   `----
  help: Consider using 'export default' or another module format instead.

Tests

  • Rust unit test: covers the location header, the code frame, decoding a file: URL name, and that messages are not wrapped.
  • packages/integrate-vitest/__tests__/diagnostics.spec.ts: covers an ESM parse error, a CommonJS require parse error, a path containing a space, and a transform error (TS(1203)).

Verification (macOS arm64, Node 24.22)

cargo test --all-features, cargo clippy --all-targets --all-features -- -D warnings, vp run test (209 passed) and vp run lint all pass.

🤖 Generated with Claude Code

…rors

`join_errors` attached the source but formatted each diagnostic with
`to_string()`, which prints only the message, so `Failed to parse` and
`Failed to transform` gave no way to find the error in a large file.
Render each diagnostic with oxc's colorless graphical report instead: a
`path:line:column` header (the decoded path, not the `file:` URL) and
the offending lines, without wrapping the message.

Closes #839

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T07:58:40.876259Z 9779052 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c00809f52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib.rs Resolved
The code frame prints every line it shows whole, so a syntax error in a
minified file copied the entire multi-megabyte line into the error. When
a frame line exceeds 1000 bytes, or the frame exceeds 10 KB, render the
message with an `at path:line:column` location instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn
Brooooooklyn merged commit 213eb03 into main Oct 16, 2026
67 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/diagnostic-locations branch October 16, 2026 08:26
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.

Parse and transform errors do not include the line and column

1 participant