feat(semantic): add TS2670 error for global scope augmentation without declare modifier#16746
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. |
b3969c4 to
e177d94
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds semantic checking for TypeScript's TS(2670) error, which requires global scope augmentations to have the declare modifier unless they're already in an ambient context (like .d.ts files or inside declare module blocks). The check prevents incorrect usage of global { } blocks without the proper declare keyword.
Key Changes
- Adds new TypeScript semantic check for global scope augmentations requiring
declaremodifier - Updates test coverage snapshot showing one additional negative test case now passing (moduleAugmentationGlobal6_1.ts)
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/oxc_semantic/src/checker/typescript.rs |
Implements the TS(2670) diagnostic check by adding validation logic to check_ts_global_declaration |
tasks/coverage/snapshots/parser_typescript.snap |
Updates test coverage metrics and removes moduleAugmentationGlobal6_1.ts from expected failures, showing the error is now properly detected |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #16746 will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
e177d94 to
083e081
Compare

Report error when
global { }is used withoutdeclaremodifier and not in an already ambient context (like .d.ts files or insidedeclare moduleblocks).Discovered while working on #16743
🤖 generated with help from Claude Opus 4.5