Commit Graph

1582 Commits

Author SHA1 Message Date
Boshen 9fff61b940 fix(coverage): skip annexB assignmenttargettype tests in test262 conformance (#18157)
## 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)
2026-01-18 02:09:41 +00:00
Boshen c98e5b77e4 fix(parser): parse for (using of = ...) as using declaration (#18142)
## 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)
2026-01-18 00:42:17 +00:00
Boshen 830b757f81 feat(regular_expression): add Unicode 17.0 script properties (#18140)
## Summary

Add support for 4 new scripts introduced in Unicode 17.0:
- `Beria_Erfe` (`Berf`)
- `Sidetic` (`Sidt`)
- `Tai_Yo` (`Tayo`)
- `Tolong_Siki` (`Tols`)

## Test plan

- [x] 8 parser_test262 tests now pass (from 46547 → 46555 positive passed)
- [x] 1 minifier_node_compat test now passes (from 930 → 931 positive passed)
- [x] 8 semantic_test262 tests now pass (from 44911 → 44919 positive passed)
- [x] `cargo test -p oxc_regular_expression` passes

🤖 Generated with [Claude Code](https://claude.ai/code)
2026-01-17 16:47:06 +00:00
Boshen 92e27b4e01 feat(parser): reparse await expressions in unambiguous mode when ESM detected (#18139)
## 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)
2026-01-17 15:27:42 +00:00
Boshen 66b8c022ab feat(parser): implement unambiguous module parsing for JS/TS files (#18124)
## 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)
2026-01-17 13:40:28 +00:00
Boshen ba9c750f68 feat(span)!: use ModuleKind::CommonJS for .cjs and .cts file extensions (#18117)
## 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)
2026-01-17 09:10:49 +00:00
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
Boshen 08dad63678 feat(span): add sourceType: 'commonjs' support (#18089)
## 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)
2026-01-16 16:08:27 +00:00
Boshen 125962da22 fix(formatter): fix 4 prettier conformance tests (#18057) 2026-01-16 06:51:39 +00:00
Boshen a412103ef2 fix(parser): improve diagnostics for double export (#17992)
fixes #15870
2026-01-14 11:23:19 +00:00
Boshen 8687b0959f chore(submodules): update submodule SHAs to latest commits (#17978)
Updates submodule dependencies to their latest commits.

## Changes

- test262: `9079aee` → `6f55d0c`
- babel: `761c250` → `fc58af4`
- TypeScript: `f3770c9` → `f5ccf43`
- estree-conformance: `87a8e99` → `4980d9b`


This PR is automatically generated by the [update_submodules
workflow](https://github.com/oxc-project/oxc/blob/main/.github/workflows/update_submodules.yml).

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2026-01-14 15:13:29 +08:00
Dunqing 4d9582d762 fix(semantic): allow arguments/eval as binding identifier names and identifier reference names in .d.ts (#17910)
Fixes: https://github.com/oxc-project/oxc/issues/17776
2026-01-12 10:03:42 +00:00
camc314 ec463beb63 chore(oxc): remove some unused snapshot files (#17803) 2026-01-09 12:04:41 +00:00
camc314 7422b7ea25 fix(parser/trivia): correctly mark whether a block comment is on a newline (#17754)
CI is green(er) https://github.com/oxc-project/monitor-oxc/actions/runs/20788815777/job/59705840652
2026-01-08 12:34:40 +00:00
Dunqing 2261e6e65b feat(semantic): improve error message to add # for private identifiers (#17779)
```js
class A {
    #a;
    #a
}
```

Chrome devtool throws:

`VM411:3 Uncaught SyntaxError: Identifier '#a' has already been declared`
2026-01-08 09:06:40 +00:00
camc314 5755b2d827 fix(semantic): report duplicate private identifier for static and instance elements (#17591)
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
2026-01-08 03:02:55 +00:00
leaysgur 0c1c1c8084 fix(tasks/coverage): Update Expand format option usage (#17769)
Part of #17330

Do not use `Expand::Always`.
2026-01-08 01:25:31 +00:00
Copilot 59a6228ef9 fix(parser): detect TS1363 error for type-only imports with mixed default and named/namespace bindings (#17712)
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.


- Fixes oxc-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>
2026-01-06 14:45:14 +00:00
Sysix 6870b6470b feat(parser): add TS1363 error code (#17609)
TS Playground: https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnAYhCARFAzAQwFcAbGAGjgG84AhAqS+gLzgF848oIQ4AiEBAAmpFHwDcQA

found in `tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/import-type-declaration-error/input.ts`

The span is not correct, but I think this is still better then nothing :)
The span should be only on the specifiers, not on the complete import declaration.
2026-01-05 08:58:35 +00:00
camc314 a7e16436da feat(parser): add TS2528 error code to duplicate_default_export diagnostic (#17558) 2026-01-02 12:55:48 +00:00
Boshen 423c27e260 test(rust): reenable lib tests that only run for code coverage 2026-01-01 11:12:14 +08:00
Boshen 0c4e9cf50d chore(submodules): update submodule SHAs to latest commits (#17456)
Updates submodule dependencies to their latest commits.

## Changes

- babel: `cbdc42f` → `761c250`
- TypeScript: `2dfdbba` → `f3770c9`
- estree-conformance: `2e7394c` → `87a8e99`


This PR is automatically generated by the [update_submodules
workflow](https://github.com/oxc-project/oxc/blob/main/.github/workflows/update_submodules.yml).

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-12-29 19:57:32 +08:00
Dunqing 42ad9d6794 fix(formatter): JSXFragment missed a leading semicolon when semicolon is disabled (#17386)
Add a leading `;` for the `JSXFragment` to solve a syntax error caused by the semicolon being disabled.
2025-12-29 08:46:54 +00:00
Boshen 8f98fa0d4e test(rust): disable empty test and doctest targets (#17409)
## 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)
2025-12-28 11:44:19 +00:00
Dunqing a7d4878bf8 test(formatter): run conformance tests with different options (#17261)
Context: https://github.com/oxc-project/oxc/issues/17151#issuecomment-3680097759

We have to run conformance tests with different options from the defaults, especially those options (semicolon, quote props) that can cause a syntax error if there is a bug
2025-12-24 01:20:03 +00:00
Boshen 58323b0b93 chore(submodules): update submodule SHAs to latest commits (#17287)
Updates submodule dependencies to their latest commits.

## Changes

- babel: `a6b5863` → `cbdc42f`
- estree-conformance: `18b46dd` → `2e7394c`


This PR is automatically generated by the [update_submodules
workflow](https://github.com/oxc-project/oxc/blob/main/.github/workflows/update_submodules.yml).

Co-authored-by: graphite-app <96075541+graphite-app@users.noreply.github.com>
2025-12-23 11:18:31 +08:00
Boshen 66b47b1a5b chore(submodules): update submodule SHAs to latest commits (#17274)
Updates submodule dependencies to their latest commits.

## Changes

- test262: `84082e2` → `9079aee`
- babel: `84d21e4` → `a6b5863`
- TypeScript: `b78f089` → `2dfdbba`
- estree-conformance: `4f260c1` → `18b46dd`


This PR is automatically generated by the [update_submodules
workflow](https://github.com/oxc-project/oxc/blob/main/.github/workflows/update_submodules.yml).

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-12-22 21:38:11 +08:00
Boshen 4ac23e1d1a feat(parser): produce syntax error for ({ foo(bar) }) (#17267)
closes #17265
2025-12-22 12:12:16 +00:00
camc314 a15e1839e0 feat(parser): change span for missing initializer in decleration (#17134) 2025-12-22 10:37:08 +00:00
camc314 3ee71b0fcc feat(parser): add diagnostic for parameters with question mark and initializer (#17132) 2025-12-22 10:24:28 +00:00
camc314 3984750c69 refactor(all)!: remove binding pattern wierdness (#15925)
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()),
                    ),
```
2025-12-22 10:04:20 +00:00
camc314 d99134d70c feat(parser): improve diagnostic message for phase imports (#17092)
We now produce the same error codes as typescript
2025-12-21 08:14:16 +00:00
sapphi-red 3e2ae7b6e6 feat(regular_expression): improve error messages (#16953)
Improved error messages for regex parse failures.
2025-12-19 02:22:12 +00:00
overlookmotel d1ce274d39 test(estree): update estree-conformance submodule (#17066)
Bump `estree-conformance` and `test262` submodules.

`estree-conformance` submodule now contains snapshots for tokens conformance testing: https://github.com/oxc-project/estree-conformance/pull/131 & https://github.com/oxc-project/estree-conformance/pull/134
2025-12-18 16:03:24 +00:00
sapphi-red 5a2af88926 fix(regular_expression): correct named capture group reference error (#16952)
The error message was swapped.
```diff
-  × Invalid regular expression: Group specifier is empty
+  × Invalid regular expression: Invalid named reference
    ╭─[test262/test/language/literals/regexp/named-groups/invalid-dangling-groupname-2-u.js:21:9]
 20 │
 21 │ /(?<a>a)\k<ab>/u;
    ·         ──────
    ╰────
```
2025-12-17 00:38:14 +00:00
sapphi-red cb515fac28 feat(parser): improve error message for yield as identifier usage (#16950)
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
```
2025-12-16 11:30:44 +00:00
sapphi-red dcc856bbdf feat(parser): add help for new_dynamic_import error (#16949)
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
```
2025-12-16 11:30:44 +00:00
sapphi-red c3c79f84e5 feat(parser): improve import attribute value error message (#16948)
Improved import attribute value parse error message.

**Before**
```
  × Unexpected token
   ╭─[babel/packages/babel-parser/test/fixtures/es2025/import-attributes/valid-syntax-export-with-invalid-value/input.js:1:63]
 1 │ export { default } from "foo.json" with { type: "json", lazy: true, startAtLine: 1 };
   ·                                                               ────
   ╰────
```
**After**
```
  × Only string literals are allowed as module attribute values.
   ╭─[babel/packages/babel-parser/test/fixtures/es2025/import-attributes/valid-syntax-export-with-invalid-value/input.js:1:63]
 1 │ export { default } from "foo.json" with { type: "json", lazy: true, startAtLine: 1 };
   ·                                                               ────
   ╰────
  help: Wrap this with quotes
```
2025-12-16 11:30:43 +00:00
Boshen e7edd492dc chore(submodules): update submodule SHAs to latest commits (#16922) 2025-12-16 11:17:56 +08:00
Boshen 3bd05545af chore(submodules): update submodule SHAs to latest commits (#16909)
Updates submodule dependencies to their latest commits.

## Changes

- test262: `c0cf527` → `947fee3`
- babel: `3591b24` → `84d21e4`
- TypeScript: `c21f73f` → `0a07132`
- estree-conformance: `1f2816b` → `e0aa1b4`

This PR is automatically generated by the [update_submodules workflow](https://github.com/oxc-project/oxc/blob/main/.github/workflows/update_submodules.yml).
2025-12-15 15:45:25 +00:00
overlookmotel 75f9800166 test(parser): combine test cases for let as identifier (#16861)
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.
2025-12-14 21:30:55 +00:00
Copilot cb88414309 fix(parser): consume semicolon after let.x and let?.x (#16857)
`let.x;` and `let?.x;` were parsed as two statements
(ExpressionStatement + EmptyStatement) instead of one. This caused
codegen idempotency failures.

**Root cause**: In `parse_let()`, the branch handling member access and
optional chaining on `let` directly constructed the statement without
consuming the semicolon:

```rust
} else if matches!(peeked, Kind::Dot | Kind::QuestionDot | Kind::LParen) {
    let expr = self.parse_expr();
    self.ast.statement_expression(self.end_span(span), expr)  // semicolon left unparsed
```

**Fix**: Call `parse_expression_statement()` to apply ASI:

```rust
} else if matches!(peeked, Kind::Dot | Kind::QuestionDot | Kind::LParen) {
    let expr = self.parse_expr();
    self.parse_expression_statement(span, expr)  // consumes semicolon
```

This matches the pattern used in other branches of the same function.

<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>Parser: `let.x;` or `let?.x;` is parsed as 2
statements</issue_title>
> <issue_description>Fixing oxc-project/oxc#16839 surfaced another
obscure bug.
> 
> ```js
> let.x;
> let?.x;
> ```
> 
> These are each parsed as 2 statements - 1 x `ExpressionStatement` + 1
x `EmptyStatement`.
> 
>
[Playground](https://playground.oxc.rs/#eNptU8Fu2zAM/Reds6ErMKDITkO7AAO6tVuH9bILLdOuUlnSSDpJYeTfS7mWkkNPth5F8vHxaTLWrI1H+Xj48i+YlYlmPRkaQ/54F8SsO/CMK9NFGkAEqSJCEDjDFXEcPQi2N2g9EIiLgWtw/+QEOYHFCg0Qen862jgkQj6lsI1Jw0JjPrwMTfTlZLt+uXZcmQTEmdhk8CAYWPvqVHbLOhB4H/e/UUYKd6Owa3EzBpuplVK5J9IO74E0t6Bz3t+r70HIaUVbA4xKW5z9RhRpQZVDFmvmoP9nWk1mZPwDzWkogebRtfJk1pcrg6G9625d0CmN75Ru0m6yxK8utJvLEv0ao5x02vLh4R34fz7dU0zaywB/CIgttlpTF+WUXn8dhwFyzHtFdQ5Xh9VZ9mV+je/hJWvXENhnlAddmqaXywWFAd+YL/1js0UrjwRJaxRRc6OZ61dRIZtRGSKdpala1UdveglQj+o7g3x58emzFlAFb7DTnE2kaw/MG4e+rQvBQ0JyAwYBr86Lary6GI0OTir6AwVaEBVh2dr7jp0MK9mku0cKoJ4rVG1sscf5cYS842rHLbdRX9KiZghR5loF8diXu3OV4vNslvIIdPKYbnGHtegzYvqpKhfvzKnqx+g36s2csUNqIp9p6ULeQQ7Vv6PC7SxfhuvfMeNZZmAxx1f2XG/6)
> 
> Once fixed, this idempotency test failure for `oxc_codegen` should be
resolved:
> 
>
https://github.com/oxc-project/oxc/blob/c7c05ba2612ca84978214cff7c1e9e836a5b319b/tasks/coverage/snapshots/codegen_misc.snap#L4</issue_description>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> </comments>
> 


</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes oxc-project/oxc#16856

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: overlookmotel <557937+overlookmotel@users.noreply.github.com>
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-12-14 21:14:44 +00:00
Copilot d3208dc969 fix(parser): parse let?.x (#16840)
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>
2025-12-14 19:26:57 +00:00
camc314 92788c7994 fix(semantic): add TS error code 1235 to namespace declaration diagnostic (#16747)
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
2025-12-11 13:27:55 +00:00
camc314 083e08144e feat(semantic): add TS2670 error for global scope augmentation without declare modifier (#16746)
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
2025-12-11 13:27:54 +00:00
leaysgur afd6c44cd7 feat(oxfmt): Support quoteProps: consistent in Oxfmtrc (#16721)
Follow up #16677, fixes #16247.
2025-12-11 02:03:49 +00:00
Dunqing 686f2b7aac feat(formatter): support consistent quote props (#16677)
### 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.
2025-12-11 00:51:23 +00:00
camc314 0be98b94e8 fix(semantic): add TS1016 error code to required parameter after optional diagnostic (#16685)
I noticed this while looking at https://discord.com/channels/1079625926024900739/1448256490904354931
2025-12-10 12:00:25 +00:00
Boshen 0a3bb7bede chore(submodules): update submodule SHAs to latest commits (#16617)
Updates submodule dependencies to their latest commits.

## Changes

- test262: `d0994d6` → `c0cf527`
- babel: `7958603` → `3591b24`
- TypeScript: `669c25c` → `c21f73f`
- estree-conformance: `3e67aec` → `1f2816b`


This PR is automatically generated by the [update_submodules
workflow](https://github.com/oxc-project/oxc/blob/main/.github/workflows/update_submodules.yml).

Co-authored-by: graphite-app <96075541+graphite-app@users.noreply.github.com>
2025-12-10 15:28:16 +08:00
camc314 75d489ad54 fix(semantic): add TS error code to function implementation missing diagnostic (#16518) 2025-12-08 12:11:34 +00:00