Skip to content

feat(parser): improve error message for using declarations with export#15266

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-03-feat_parser_improve_error_message_for_using_declarations_with_export_
Nov 4, 2025
Merged

feat(parser): improve error message for using declarations with export#15266
graphite-app[bot] merged 1 commit intomainfrom
11-03-feat_parser_improve_error_message_for_using_declarations_with_export_

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Nov 4, 2025

Add a better error message for export using x = something and export await using x = something.

@github-actions github-actions bot added A-parser Area - Parser C-enhancement Category - New feature or request labels Nov 4, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sapphi-red sapphi-red requested a review from Boshen November 4, 2025 12:10
@sapphi-red sapphi-red marked this pull request as ready for review November 4, 2025 12:10
Copilot AI review requested due to automatic review settings November 4, 2025 12:10
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 PR improves error messaging for exported using declarations in TypeScript/JavaScript. Instead of reporting a generic "Unexpected token" error when export using or export await using is encountered, it now provides a specific error message explaining that using declarations cannot be exported directly, along with helpful guidance on how to properly export them.

  • Replaced generic "Unexpected token" errors with specific "Using declarations cannot be exported directly" error messages
  • Added helpful error messages suggesting to split the export and declaration into separate statements
  • Made is_using_declaration() function public to enable reuse across modules

Reviewed Changes

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

Show a summary per file
File Description
crates/oxc_parser/src/diagnostics.rs Added new using_declaration_cannot_be_exported diagnostic function with helpful message
crates/oxc_parser/src/ts/statement.rs Added handling for export using and export await using cases to emit the new specific error
crates/oxc_parser/src/js/statement.rs Changed visibility of is_using_declaration() from private to public
tasks/coverage/snapshots/parser_typescript.snap Updated test snapshots with improved error messages
tasks/coverage/snapshots/parser_babel.snap Updated test snapshots with improved error messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 4, 2025

CodSpeed Performance Report

Merging #15266 will not alter performance

Comparing 11-03-feat_parser_improve_error_message_for_using_declarations_with_export_ (d3e8f21) with main (d6996d0)

Summary

✅ 37 untouched

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Nov 4, 2025
Copy link
Member

Boshen commented Nov 4, 2025

Merge activity

…rt` (#15266)

Add a better error message for `export using x = something` and `export await using x = something`.
@graphite-app graphite-app bot force-pushed the 11-03-feat_parser_improve_error_message_for_using_declarations_with_export_ branch from d3e8f21 to e62d14a Compare November 4, 2025 13:06
@graphite-app graphite-app bot merged commit e62d14a into main Nov 4, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 11-03-feat_parser_improve_error_message_for_using_declarations_with_export_ branch November 4, 2025 13:12
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments