Files
oxc-project__oxc/tasks/coverage/misc/pass/script-using-in-block.js
Boshen fb181ccdff fix(semantic): error on using at top level in scripts (#18090)
## Summary

- Add check to error on `using` declarations at the top level of scripts
- `using` declarations require block scope semantics and are not allowed
at the top level of scripts

`using` declarations are allowed:
- At the top level of ES modules
- At the top level of CommonJS modules (files are wrapped in a function)
- Inside any block scope in scripts

But NOT at the top level of scripts.

Closes #11862

## Test plan

- [x] Added test case
`tasks/coverage/misc/fail/script-top-level-using.js` for invalid usage
- [x] Added test case
`tasks/coverage/misc/pass/script-using-in-block.js` for valid usage in
block
- [x] All existing tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 12:18:26 +08:00

5 lines
67 B
JavaScript

// 'using' is allowed inside blocks in scripts
{
using x = {};
}