## Summary
- Skip annexB assignmenttargettype tests in test262 conformance suite
- These tests require call expressions to be valid assignment targets in non-strict mode (e.g., `f() = 1`, `f()++`, `for (f() in [1]) {}`)
- This is an Annex B "web reality" feature that oxc intentionally does not support
## Test plan
- [x] `cargo coverage -- parser` shows 100% pass rate (46556/46556)
- [x] All affected snapshots updated
🤖 Generated with [Claude Code](https://claude.com/claude-code)
## Summary
- Fix parsing of `for (using of = null;;)` as a using declaration where `of` is the binding identifier
- Previously, the parser incorrectly treated `of` as the keyword starting a for-of loop
The fix uses a lookahead to check if the token after `of` is `=`, `;`, or `:`, matching TypeScript's parser behavior.
## Test plan
- `cargo coverage -- parser` - conformance tests pass
- `cargo test -p oxc_parser` - unit tests pass
🤖 Generated with [Claude Code](https://claude.ai/code)
## Summary
- Implements TypeScript-compatible await expression reparsing for unambiguous mode
- When `sourceType` is `unambiguous`, `await / 0 /u; export {}` now correctly parses as `await /0/u` (await expression with regex)
- Follows TypeScript's two-pass approach: initially parse `await` as identifier, then reparse with await context if ESM is detected
## Test plan
- Added `tasks/coverage/misc/pass/unambiguous-await-regex.js` test case
- Moved `tasks/coverage/misc/fail/babel-16776-s.js` to pass (now parses as division in script mode)
- All parser tests pass
- Conformance tests show improvements in parser_babel and semantic_babel
🤖 Generated with [Claude Code](https://claude.com/claude-code)
## Summary
- Implements speculative/unambiguous parsing for `.js`, `.jsx`, `.ts`, and `.tsx` files
- Instead of assuming module or script upfront, parses with `ModuleKind::Unambiguous` and upgrades to module mode when ESM syntax is detected
- ESM indicators: `import`, `export`, `import.meta` (NOT top-level await alone)
- Defers top-level await errors until module type is resolved
- Vue loader upgrades unambiguous scripts to module mode
- Updates linter tests to use explicit ESM extensions (`.mjs`/`.mts`) where needed
## Test plan
- [x] All parser tests pass
- [x] All linter tests pass
- [x] All semantic tests pass
- [x] Coverage conformance tests updated
🤖 Generated with [Claude Code](https://claude.com/claude-code)
## Summary
- Updates `SourceType::from_path()` to return `ModuleKind::CommonJS` for `.cjs`/`.cts` files (previously returned `ModuleKind::Script`)
- Fixes `eslint/no-eval` to check `!is_module()` instead of `is_script()` to handle both scripts and CommonJS (matching ESLint's `sourceType: "commonjs"` behavior)
- Fixes `eslint/no-redeclare` to run for both scripts and CommonJS files
- Updates tests to use proper CommonJS assertions
This follows up on #18089 which added `ModuleKind::CommonJS` support but didn't update the file extension mapping.
## Test plan
- [x] `cargo test -p oxc_span`
- [x] `cargo test -p oxc_linter`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
## 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>
## Summary
- Add `ModuleKind::CommonJS` variant to support CommonJS module type in the parser
- Enable top-level `return` statements (CommonJS files are wrapped in a function)
- Enable top-level `new.target` (allowed in CommonJS function wrapper)
- Add proper errors for `import`/`export` statements in CommonJS
- Add proper errors for `import.meta` in CommonJS
The CommonJS source type can be set via:
- `SourceType::with_commonjs(true)` method
- Babel's `sourceType: "commonjs"` option
Closes#16200
## Test plan
- [x] Added test cases in `tasks/coverage/misc/pass/` for valid CommonJS features
- [x] Added test cases in `tasks/coverage/misc/fail/` for invalid CommonJS usage
- [x] Enabled Babel conformance tests for `sourceType: "commonjs"`
- [x] All existing tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Previously, TypeScript files with both a static private identifier and an instance private identifier with the same name (e.g., `static #m` and `#m()`) were not being reported as errors.
Closes#17518
The parser was not detecting `import type foo, {} from 'bar';` and `import type A, * as NS from 'mod';` as errors. TypeScript's TS1363 requires that type-only imports specify either a default import or named/namespace bindings, but not both—even when the named bindings list is empty.
## Changes
- **Parser**: Added TS1363 check in `parse_import_declaration_specifiers` when encountering `LCurly` or
`Star` token after a type-only default import
- **Module record**: Removed redundant TS1363 validation that couldn't detect empty `{}` cases
- **Error span**: Now points at the default specifier instead of the entire import statement
## Examples
The following patterns now correctly error with TS1363:
```typescript
// Empty named bindings
import type foo, {} from 'bar';
// Named bindings with specifiers
import type foo, { bar } from 'baz';
// Namespace import
import type A, * as NS from 'mod';
```
The parser-level check is comprehensive and catches all cases including
empty braces and namespace imports, which weren't being detected
previously.
- Fixesoxc-project/oxc#17684
---------
Signed-off-by: Cameron <cameron.clark@hey.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Co-authored-by: Cameron <cameron.clark@hey.com>
## Summary
- Disable `test = false` and `doctest = false` for crates that have no tests
- Reduces CI noise from "0 passed; 0 failed" output
- Saves compilation time for empty test targets
**Affected crates:**
- `oxc_ast_macros` - lib test
- `oxc_language_server` - bin test, lib doctest
- `oxc_napi` - lib test
- `oxc_syntax` - lib doctest
- `oxc_compat_data` - bin test
- `oxc_coverage` - lib test
- `oxc_linter_codegen` - bin test
- `oxc_prettier_conformance` - lib test
- `oxc_transform_conformance` - lib test
- `vscode_docs` - bin test
- `website_common` - lib test, lib doctest
## Test plan
- [x] `cargo test` passes with no empty test suites
🤖 Generated with [Claude Code](https://claude.com/claude-code)
fixes#11489
Note, in quite a few places i changed the span we report on to look something like this, the only reason for this is to reduce the diff in some of the snapshots
```
decl.type_annotation.as_ref().map_or_else(
|| decl.id.span(),
|type_annotation| decl.id.span().merge(type_annotation.span()),
),
```
Improved error message for `yield` as identifier usage.
**Before**
```
× Cannot use `yield` as an identifier in a generator context
╭─[test262/test/language/expressions/generators/yield-weak-binding.js:17:33]
16 │
17 │ var g = function*() { yield 3 + yield 4; };
· ─────
╰────
```
**After**
```
× Cannot use `yield` as an identifier in a generator context
╭─[test262/test/language/expressions/generators/yield-weak-binding.js:17:33]
16 │
17 │ var g = function*() { yield 3 + yield 4; };
· ─────
╰────
help: Wrap this in parentheses if you want to use a `yield` expression here
```
Added help for `new_dynamic_import` error.
**Before**
```
× Cannot use new with dynamic import
╭─[babel/packages/babel-parser/test/fixtures/es2020/dynamic-import/invalid-new/input.js:1:5]
1 │ new import("foo");
· ─────────────
╰────
```
**After**
```
× Cannot use new with dynamic import
╭─[babel/packages/babel-parser/test/fixtures/es2020/dynamic-import/invalid-new/input.js:1:5]
1 │ new import("foo");
· ─────────────
╰────
help: Wrap this with parenthesis
```
Follow-on after #16840 and #16857. We had a few test cases relating to the same thing, and one of them called the undescriptive `oxc.js`. Combine them, and rename the test case files with a more accurate name.
Fixes#16839.
Make parser parse `let?.x` successfully.
There's a failure in codegen idempotency tests, but that's an unrelated
and pre-existing bug, so am leaving that to another PR.
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
Add TypeScript error code to the "namespace declaration not allowed" error message for consistency with other TS diagnostics.
🤖 generated with help from Claude Opus 4.5
Report error when `global { }` is used without `declare` modifier and not in an already ambient context (like .d.ts files or inside `declare module` blocks).
Discovered while working on https://github.com/oxc-project/oxc/issues/16743🤖 generated with help from Claude Opus 4.5
### Summary
close: https://github.com/oxc-project/oxc/issues/16247
The Prettier documentation is [Quote props](https://prettier.io/docs/next/options#quote-props).
Support `consistent` in all object-like nodes, including `ObjectExpression`, `Class`, `TSTypeLiteral`, `TSInterfaceDeclaration`, and `WithClause`.
### Example:
```ts
// ============================================
// ObjectExpression - object literals
// ============================================
const obj = {
normal: "value",
"needs-quote": "value", // triggers consistent quoting for all keys
};
// Nested objects are handled independently
const nested = {
outer: {
inner: "value",
"inner-key": "value", // only inner object gets quoted
},
outerKey: "value", // outer stays unquoted
};
// ============================================
// Class - properties, methods, and accessors
// ============================================
class MyClass {
prop1 = "value";
"prop-2" = "value"; // triggers consistent quoting
method1() {}
"method-2"() {} // triggers consistent quoting for methods too
get getter1() { return 1; }
get "getter-2"() { return 2; } // triggers consistent quoting for accessors too
set setter1(v) {}
set "setter-2"(v) {}
}
// ============================================
// WithClause - import/export attributes
// ============================================
import data from "./data.json" with {
type: "json",
"custom-attr": "value", // triggers consistent quoting
};
export { foo } from "./foo.js" with {
key: "value",
"x-y": "other",
};
// ============================================
// TSInterfaceDeclaration (TypeScript)
// ============================================
interface MyInterface {
prop1: string;
"prop-2": number; // triggers consistent quoting
method1(): void;
"method-2"(): string; // triggers consistent quoting for method signatures too
}
// ============================================
// TSTypeLiteral (TypeScript)
// ============================================
type MyType = {
field1: string;
"field-2": number; // triggers consistent quoting
method(): void;
"method-2"(): string; // triggers consistent quoting for method signatures too
};
// Inline type literal
function process(param: { x: string; "y-z": number }): void {}
```
NOTE: I've found a Prettier bug, that is, `TSMethodSignature` is not being wrapped in quotes! But it should be, see [Prettier Playground](https://prettier.io/playground/#N4Igxg9gdgLgprEAuEMCeAHOACAtnGACwgBMBnbAXm2AB0ps8DiSAKASiWwDcIBLEgG56jAOT4ipALQAmURy68BwqAF8VIADQgIGGH2hlkoAIYAnMxADuABXMIjKEwBsrJtEe0AjMybABrAgBlE3wAGT4oOGQAMxcyOG0ILwArODAYAHVfDGQQDDM4BLNuaO9fAOCMP0iAc2QYMwBXRJAE3D4G5ta4AA8sMz58WBcAeQGTGAgzGwgyPn1oPIQSLRA+gaGEGBcAFTgzKHM+Itj41vmoWuc4AEUmiHgz5wTtFLJeoLqb+8fopDiL1aAEcHvAbJYMI5wIY+GR4IhtI0THxnHUAMIQXC4Ex5FzONaXa5wACCMEafC8TXBBwiUWerxAhBguGcmUICyK1TAcCCDgWfG4CzQeTAZE8IG4LQAklASNsgmBBnoSXKgugbgzWgU5nBsiZcigCkUDqU1itRjE6f8QM4YmtIsUYBCTLUcVrtNUzMU8l4TF44M4pDAJQVIlkBERkAAOAAM2kKoL4hRdbtxAPOSP9mUjhGQMm0TQSu39jkBjLguADJHlJDCJiuTVdcAAYtMceS6njqRAQKpVEA)
### Not implemented case
There are still two failed tests because NumericLiterals doesn't wrap in quotes in `consistent`, which is intended because Prettier only wraps them when the parser is `JavaScript` or `Flow`
For example:
Input:
```
const A = {
"k-b": a,
2: b,
}
```
Output:
With `babel` or `flow` parser
```ts
const A = {
"k-b": a,
"2": b,
};
```
With `babel-ts` or `typescript` parser
```ts
const A = {
"k-b": a,
2: b,
};
```
So, for simplicity, and since oxc includes parsing TS, we don't wrap `NumericLiteral` in quotes at all.
### Tests
All tests are generated by Claude with the proper prompt, covering all code in this PR.