-
-
Notifications
You must be signed in to change notification settings - Fork 723
fix(parser): forbid invalid modifiers on module and global
#15723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(parser): forbid invalid modifiers on module and global
#15723
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
CodSpeed Performance ReportMerging #15723 will not alter performanceComparing Summary
|
3d430d9 to
522810e
Compare
74572d3 to
6b4cdae
Compare
6b4cdae to
cbb27fd
Compare
522810e to
6fcc1a5
Compare
3f085e4 to
8523f78
Compare
8523f78 to
4e1248e
Compare
There was a problem hiding this 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 adds validation to forbid invalid modifiers on module and global declarations in TypeScript. Previously, illegal syntax with multiple modifiers (like protected accessor readonly async declare global {}) would be parsed without error.
- Adds
verify_modifierscalls to validate that only thedeclaremodifier is allowed on module and global declarations - Ensures consistency with similar validation done for other TypeScript declarations (enums, type aliases, interfaces)
Reviewed Changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_parser/src/ts/statement.rs | Adds modifier validation for parse_ambient_external_module_declaration, parse_module_or_namespace_declaration, and parse_ts_global_declaration functions to reject invalid modifiers |
| tasks/coverage/snapshots/parser_typescript.snap | Updates test snapshots to reflect new error messages for invalid export modifier on module declarations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
Error on invalid modifiers before `module` and `global` declarations.
Previously illegal syntax like this would be parsed without error:
```ts
protected accessor readonly async declare global {}
protected accessor readonly async global {}
protected accessor readonly async module "foo" {}
```
Discovered this bug while working on #15712.
Similar to #11713.
4e1248e to
6f597bd
Compare
Error on invalid modifiers before `module` and `global` declarations.
Previously illegal syntax like this would be parsed without error:
```ts
protected accessor readonly async declare global {}
protected accessor readonly async global {}
protected accessor readonly async module "foo" {}
```
Discovered this bug while working on #15712.
Similar to #11713.
6f597bd to
d4ff004
Compare

Error on invalid modifiers before
moduleandglobaldeclarations.Previously illegal syntax like this would be parsed without error:
Discovered this bug while working on #15712.
Similar to #11713.