feat(parser): report more invalid modifier locations#13368
feat(parser): report more invalid modifier locations#13368Boshen merged 2 commits intooxc-project:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the TypeScript parser to better validate modifier locations and report more specific diagnostic errors when modifiers are used incorrectly. The changes implement stricter checks for where modifiers can be placed in TypeScript code.
- Added support for tracking
DefaultandExportmodifiers in the modifier system - Introduced new TypeScript diagnostic error codes (1029, 1031, 1070) for invalid modifier usage
- Split constructor functions from class methods to enable more precise modifier validation
Reviewed Changes
Copilot reviewed 7 out of 32 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_parser/src/modifiers.rs | Added Default and Export modifier variants with validation logic |
| crates/oxc_parser/src/lexer/kind.rs | Extended modifier detection to include Default and Export tokens |
| crates/oxc_parser/src/js/mod.rs | Added Constructor as a distinct function kind |
| crates/oxc_parser/src/js/function.rs | Updated parameter modifier validation with constructor-specific rules |
| crates/oxc_parser/src/js/class.rs | Added modifier validation for class elements and updated constructor parsing |
| crates/oxc_parser/src/ts/statement.rs | Added modifier validation for type members |
| crates/oxc_parser/src/diagnostics.rs | Added three new TypeScript diagnostic error functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Instrumentation Performance ReportMerging #13368 will not alter performanceComparing Summary
|
31be6d7 to
d45da2d
Compare
|
I'm unsure about the failing allocations CI check... I did run the command locally, committed my changes but it still failed. Just reset back and force pushed to remove the attempt of making this CI check happy. |
Merge activity
You must have a Graphite account in order to use the merge queue. Create an account and try again using this link |
|
Great work! |
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
Changes
tasks/coverage/misc/failDefaultandExportto modifiersFunctionKind::ConstructorfromFunctionKind::ClassMethodto differentiate when verifying modifiers of formal parameterResults
parser_babel.snapandparser_typescript.snapincreased