Skip to content

fix(parser): improve diagnostics around modifier checks#13526

Merged
Boshen merged 4 commits intooxc-project:mainfrom
ulrichstark:improve-diagnostics-around-modifier-checks
Sep 9, 2025
Merged

fix(parser): improve diagnostics around modifier checks#13526
Boshen merged 4 commits intooxc-project:mainfrom
ulrichstark:improve-diagnostics-around-modifier-checks

Conversation

@ulrichstark
Copy link
Contributor

@ulrichstark ulrichstark commented Sep 2, 2025

Follow up to #13368.
Closes #11713 by fixing five more cases mentioned in #11713 (comment).

Other changes:

  • Added TS(1024) diagnostic
  • Fixed the broken oxc-11713-13.ts test file
  • Made TS(1070) not report redundantly if it's actually the responsibility of TS(1071)
  • Branch off the more specific TS(1028) diagnostic from the general TS(1030) diagnostic like TypeScript does
  • Remove incorrect code to parse modifiers on typescript this parameter

Copilot AI review requested due to automatic review settings September 2, 2025 19:04
@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels Sep 2, 2025
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 improves TypeScript parser diagnostics around modifier validation, addressing five specific cases from issue #11713. The changes focus on providing more accurate error messages for invalid modifier usage and fixing redundant diagnostic reporting.

  • Enhanced modifier validation for method signatures, index signatures, and class elements
  • Added new TS(1024) diagnostic for modifiers that can only appear on property declarations or index signatures
  • Generalized the TS(1029) diagnostic to handle various modifier ordering issues beyond just export/declare

Reviewed Changes

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

Show a summary per file
File Description
crates/oxc_parser/src/ts/types.rs Added readonly modifier validation for method signatures and removed redundant index signature validation
crates/oxc_parser/src/ts/statement.rs Moved index signature modifier validation earlier to avoid redundant error reporting
crates/oxc_parser/src/modifiers.rs Generalized export/declare modifier ordering diagnostic
crates/oxc_parser/src/js/class.rs Enhanced modifier validation for class index signatures and method declarations
crates/oxc_parser/src/diagnostics.rs Added new TS(1024) diagnostic and generalized TS(1029) for modifier ordering

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 2, 2025

CodSpeed Instrumentation Performance Report

Merging #13526 will not alter performance

Comparing ulrichstark:improve-diagnostics-around-modifier-checks (ac3e7d8) with main (91759c6)

Summary

✅ 37 untouched benchmarks

@Boshen
Copy link
Member

Boshen commented Sep 9, 2025

Thank you for the nice work!

@Boshen Boshen merged commit f795d69 into oxc-project:main Sep 9, 2025
27 checks passed
@ulrichstark ulrichstark deleted the improve-diagnostics-around-modifier-checks branch September 9, 2025 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forbid invalid modifiers

3 participants