Commit graph

737 commits

Author SHA1 Message Date
renovate[bot]
e00e3abd84
chore(deps): update rust crates (major) (#8739)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [oxc_resolver](https://redirect.github.com/oxc-project/oxc-resolver) |
workspace.dependencies | major | `3` -> `4` |
| [ureq](https://redirect.github.com/algesten/ureq) |
workspace.dependencies | major | `2.12.1` -> `3.0.0` |

---

### Release Notes

<details>
<summary>oxc-project/oxc-resolver (oxc_resolver)</summary>

###
[`v4.0.0`](https://redirect.github.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#400---2025-01-20)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-resolver/compare/oxc_resolver-v3.0.3...oxc_resolver-v4.0.0)

##### <!-- 0 -->Features

- \[**breaking**] generic fs cache `type Resolver =
ResolverGeneric<FsCache<FileSystemOs>>`
([#&#8203;358](https://redirect.github.com/oxc-project/oxc-resolver/issues/358))
- \[**breaking**] `PackageJson` and `TsConfig` traits
([#&#8203;360](https://redirect.github.com/oxc-project/oxc-resolver/issues/360))

##### <!-- 2 -->Performance

- use papaya instead of dashmap
([#&#8203;356](https://redirect.github.com/oxc-project/oxc-resolver/issues/356))

</details>

<details>
<summary>algesten/ureq (ureq)</summary>

###
[`v3.0.0`](https://redirect.github.com/algesten/ureq/blob/HEAD/CHANGELOG.md#300)

[Compare
Source](https://redirect.github.com/algesten/ureq/compare/2.12.1...3.0.0)

- Replace RequestBuilder Deref with explicit wrappers
([#&#8203;944](https://redirect.github.com/algesten/ureq/issues/944))
- Remove dependency on `url` crate
([#&#8203;943](https://redirect.github.com/algesten/ureq/issues/943))
- Feature `Config::save_redirect_history`
([#&#8203;939](https://redirect.github.com/algesten/ureq/issues/939))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on monday" in timezone Asia/Shanghai,
Automerge - "on monday" in timezone Asia/Shanghai.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMjUuMSIsInVwZGF0ZWRJblZlciI6IjM5LjEyNS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Boshen <boshenc@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-27 12:56:52 +08:00
Boshen
99607d3f82 feat(codegen): print comments in TSTypeLiteral (#8679)
fixes #8665
2025-01-23 14:31:55 +00:00
Kevin Deng 三咲智子
178c2322f5
fix(parser): parse intrinsic TS keyword (#8627) 2025-01-21 09:54:10 +08:00
Kevin Deng 三咲智子
48717ab87c
fix(parser): parse true as TSLiteralType (#8626)
closes #8624
2025-01-21 09:50:49 +08:00
branchseer
7421a52f7c
fix(transformer/typescript): correctly resolve references to non-constant enum members (#8543)
fixes #8342

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2025-01-18 17:02:50 +08:00
Dunqing
f413bb5c64 feat(transformer/optional-chaining): change parent scope for expression when it wrapped with an arrow function (#8511) 2025-01-16 12:21:44 +00:00
Dunqing
f5c5c3c9f1 chore(coverage/runtime): skip tests which are eval in class (#8532)
These tests need performing `eval`, we cannot support them. @overlookmotel and I have agreed to ignore them to reduce the noise.
2025-01-16 05:44:32 +00:00
Valentinas Janeiko
4ce63298e8
fix(semantic)!: ensure program outlives semantic (#8455)
fixes: #8437 

In semantic builder make sure `Program` reference has a lifetime of the
Arena.

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-01-16 10:04:25 +08:00
Dunqing
06ccb51fae fix(transformer/async-to-generator): move parameters to the inner generator function when they could throw errors (#8500)
The new implementation port from [esbuild](df815ac27b/internal/js_parser/js_parser_lower.go (L355-L467)), before from `Babel`.

Babel's transform implementation for the async method is incorrect because the async method should return a rejecting promise when it throws an error. Everything is good if the errors are thrown in the async method body, but the following case will throw an error in the parameters which causes the whole program crushed not a rejecting promise. So we should move the parameters to the inner generator function when the parameters could throw an error.

Input:
```js
class Cls {
  // ReferenceError: Cannot access 'b' before initialization
  async method(a = b, b = 0) {}
}
```

Before output
```js
class Cls {
  method(a = b, b = 0) {
    return babelHelpers.asyncToGenerator(function* () {})();
  }
}
```

After output:
```js
class Cls {
  method() {
     // ReferenceError: Cannot access 'b' before initialization
    return babelHelpers.asyncToGenerator(function* (a = b, b = 0) {}).apply(this, arguments);
  }
}
```

No override tests because Babel doesn't cover this case.
2025-01-16 00:18:05 +00:00
overlookmotel
cfd783aa19
chore(coverage): bump babel submodule (#8508)
Update babel submodule for conformance tests to latest HEAD.

The test fixtures include a new one for a bug fix which @branchseer
intends to also apply to Oxc - https://github.com/babel/babel/pull/17050
(see #8342).
2025-01-15 22:58:15 +08:00
Dunqing
31746754a8
chore(coverage): update runtime snapshots (#8489)
Found a bunch of failed tests related to we don't use
`classPrivateSetter` and `classPrivateGetter` to transform private
getter and private setter. The simplest way is to add alternative helper
functions for these two. The reason we don't use I have explained in
#8132

```shell
tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-add.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «3») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitand.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «0») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitor.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «15») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitxor.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «257») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-div.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «0.5») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-exp.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «1000») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-lshift.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «96») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mod.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «1») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mult.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «6») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-rshift.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «3») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-srshift.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «3») to be true

tasks/coverage/test262/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-sub.js
transform error: Test262Error: The expression should evaluate to the result Expected SameValue(«undefined», «1») to be true
```
2025-01-14 22:06:10 +08:00
Dunqing
270245fd6e fix(transformer/typescript): correct the semantic for TSImportEqualsDeclaration transformation (#8463) 2025-01-14 11:26:50 +00:00
Dunqing
2a400d66d4
fix(transformer/typescript): retain TSImportEqualsDeclaration when it is exported 2025-01-14 19:12:23 +08:00
Dunqing
c83ce5c6cf refactor(transformer/typescript): improve transforming namespace (#8459)
I did a few things in this PR,

1. Remove `names` which store the declarations name used for checking re-declaration. (We can use SymbolTable to do it now.)
2. Correct semantic data for namespace transform
3. Simplify code
2025-01-14 09:42:31 +00:00
Dunqing
7252cb0d77 fix(isolated-declarations): unexpected error when global Symbol as property key (#8475)
close: #8469

No support to report errors for non-global `Symbol` yet, it is hard for the current architecture.
2025-01-14 05:27:17 +00:00
Dunqing
ab694b064a fix(transformer/typescript): retain TSImportEqualsDeclaration in namespace when its binding has been referenced or onlyRemoveTypeImports is true (#8458)
close: #8384
2025-01-13 05:57:30 +00:00
Dunqing
9a03bd23b9 fix(transformer/typescript): remove type-only import = when only_remove_type_imports is true (#8275)
close: https://github.com/oxc-project/oxc/issues/8230
close: https://github.com/rolldown/rolldown/issues/3287

Related PR in Babel: https://github.com/oxc-project/oxc/issues/8230

I have compared our output with TypeScript, and it is the same as `TypeScript`, Babel's implementation currently hasn't removed imports referenced by type-only `TSImportEqualsDeclaration`
2025-01-11 08:42:51 +00:00
Boshen
33d776db51
chore(tasks/coverage): ignore fn-name-cover.js in test262 minifier runtime 2025-01-10 10:47:09 +08:00
renovate
772b71c838 chore(deps): update dependency rust to v1.84.0 (#8391)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rust](https://redirect.github.com/rust-lang/rust) | minor | `1.83.0` -> `1.84.0` |

---

### Release Notes

<details>
<summary>rust-lang/rust (rust)</summary>

### [`v1.84.0`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1840-2025-01-09)

[Compare Source](https://redirect.github.com/rust-lang/rust/compare/1.83.0...1.84.0)

\==========================

<a id="
Language"></a>

## Language

-   [Allow `#[deny]` inside `#[forbid]` as a no-op](https://redirect.github.com/rust-lang/rust/pull/121560/)
-   [Show a warning when `-Ctarget-feature` is used to toggle features that can lead to unsoundness due to ABI mismatches](https://redirect.github.com/rust-lang/rust/pull/129884)
-   [Use the next-generation trait solver in coherence](https://redirect.github.com/rust-lang/rust/pull/130654)
-   [Allow coercions to drop the principal of trait objects](https://redirect.github.com/rust-lang/rust/pull/131857)
-   [Support `/` as the path separator for `include!()` in all cases on Windows](https://redirect.github.com/rust-lang/rust/pull/125205)
-   [Taking a raw ref (`raw (const|mut)`) of a deref of a pointer (`*ptr`) is now safe](https://redirect.github.com/rust-lang/rust/pull/129248)
-   [Stabilize s390x inline assembly](https://redirect.github.com/rust-lang/rust/pull/131258)
-   [Stabilize Arm64EC inline assembly](https://redirect.github.com/rust-lang/rust/pull/131781)
-   [Lint against creating pointers to immediately dropped temporaries](https://redirect.github.com/rust-lang/rust/pull/128985)
-   [Execute drop glue when unwinding in an `extern "C"` function](https://redirect.github.com/rust-lang/rust/pull/129582)

<a id="1.84.0-Compiler"></a>

## Compiler

-   [Add `--print host-tuple` flag to print the host target tuple and affirm the "target tuple" terminology over "target triple"](https://redirect.github.com/rust-lang/rust/pull/125579)
-   [Declaring functions with a calling convention not supported on the current target now triggers a hard error](https://redirect.github.com/rust-lang/rust/pull/129935)
-   [Set up indirect access to external data for `loongarch64-unknown-linux-{musl,ohos}`](https://redirect.github.com/rust-lang/rust/pull/131583)
-   [Enable XRay instrumentation for LoongArch Linux targets](https://redirect.github.com/rust-lang/rust/pull/131818)
-   [Extend the `unexpected_cfgs` lint to also warn in external macros](https://redirect.github.com/rust-lang/rust/pull/132577)
-   [Stabilize WebAssembly `multivalue`, `reference-types`, and `tail-call` target features](https://redirect.github.com/rust-lang/rust/pull/131080)
-   [Added Tier 2 support for the `wasm32v1-none` target](https://redirect.github.com/rust-lang/rust/pull/131487)

<a id="1.84.0-Libraries"></a>

## Libraries

-   [Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`](https://redirect.github.com/rust-lang/rust/pull/129329)
-   [Move `<float>::copysign`, `<float>::abs`, `<float>::signum` to `core`](https://redirect.github.com/rust-lang/rust/pull/131304)
-   [Add `LowerExp` and `UpperExp` implementations to `NonZero`](https://redirect.github.com/rust-lang/rust/pull/131377)
-   [Implement `FromStr` for `CString` and `TryFrom<CString>` for `String`](https://redirect.github.com/rust-lang/rust/pull/130608)
-   [`std::os::darwin` has been made public](https://redirect.github.com/rust-lang/rust/pull/123723)

<a id="1.84.0-Stabilized-APIs"></a>

## Stabilized APIs

-   [`Ipv6Addr::is_unique_local`](https://doc.rust-lang.org/stable/core/net/struct.Ipv6Addr.html#method.is_unique_local)
-   [`Ipv6Addr::is_unicast_link_local`](https://doc.rust-lang.org/stable/core/net/struct.Ipv6Addr.html#method.is_unicast_link_local)
-   [`core::ptr::with_exposed_provenance`](https://doc.rust-lang.org/stable/core/ptr/fn.with_exposed_provenance.html)
-   [`core::ptr::with_exposed_provenance_mut`](https://doc.rust-lang.org/stable/core/ptr/fn.with_exposed_provenance_mut.html)
-   [`<ptr>::addr`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.addr)
-   [`<ptr>::expose_provenance`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.expose_provenance)
-   [`<ptr>::with_addr`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.with_addr)
-   [`<ptr>::map_addr`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.map_addr)
-   [`<int>::isqrt`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.isqrt)
-   [`<int>::checked_isqrt`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.checked_isqrt)
-   [`<uint>::isqrt`](https://doc.rust-lang.org/stable/core/primitive.u32.html#method.isqrt)
-   [`NonZero::isqrt`](https://doc.rust-lang.org/stable/core/num/struct.NonZero.html#impl-NonZero%3Cu128%3E/method.isqrt)
-   [`core::ptr::without_provenance`](https://doc.rust-lang.org/stable/core/ptr/fn.without_provenance.html)
-   [`core::ptr::without_provenance_mut`](https://doc.rust-lang.org/stable/core/ptr/fn.without_provenance_mut.html)
-   [`core::ptr::dangling`](https://doc.rust-lang.org/stable/core/ptr/fn.dangling.html)
-   [`core::ptr::dangling_mut`](https://doc.rust-lang.org/stable/core/ptr/fn.dangling_mut.html)

These APIs are now stable in const contexts

-   [`AtomicBool::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicBool.html#method.from_ptr)
-   [`AtomicPtr::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicPtr.html#method.from_ptr)
-   [`AtomicU8::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicU8.html#method.from_ptr)
-   [`AtomicU16::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicU16.html#method.from_ptr)
-   [`AtomicU32::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicU32.html#method.from_ptr)
-   [`AtomicU64::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicU64.html#method.from_ptr)
-   [`AtomicUsize::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicUsize.html#method.from_ptr)
-   [`AtomicI8::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicI8.html#method.from_ptr)
-   [`AtomicI16::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicI16.html#method.from_ptr)
-   [`AtomicI32::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicI32.html#method.from_ptr)
-   [`AtomicI64::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicI64.html#method.from_ptr)
-   [`AtomicIsize::from_ptr`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicIsize.html#method.from_ptr)
-   [`<ptr>::is_null`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_null-1)
-   [`<ptr>::as_ref`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.as_ref-1)
-   [`<ptr>::as_mut`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.as_mut)
-   [`Pin::new`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.new)
-   [`Pin::new_unchecked`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.new_unchecked)
-   [`Pin::get_ref`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.get_ref)
-   [`Pin::into_ref`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.into_ref)
-   [`Pin::get_mut`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.get_mut)
-   [`Pin::get_unchecked_mut`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.get_unchecked_mut)
-   [`Pin::static_ref`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.static_ref)
-   [`Pin::static_mut`](https://doc.rust-lang.org/stable/core/pin/struct.Pin.html#method.static_mut)

<a id="1.84.0-Cargo"></a>

## Cargo

-   [Stabilize MSRV-aware resolver config](https://redirect.github.com/rust-lang/cargo/pull/14639/)
-   [Stabilize resolver v3](https://redirect.github.com/rust-lang/cargo/pull/14754/)

<a id="1.84-Rustdoc"></a>

## Rustdoc

-   [rustdoc-search: improve type-driven search](https://redirect.github.com/rust-lang/rust/pull/127589)

<a id="1.84.0-Compatibility-Notes"></a>

## Compatibility Notes

-   [Enable by default the `LSX` target feature for LoongArch Linux targets](https://redirect.github.com/rust-lang/rust/pull/132140)
-   [The unstable `-Zprofile` flag (“gcov-style” coverage instrumentation) has been removed.](https://redirect.github.com/rust-lang/rust/pull/131829) This does not affect the stable flags for coverage instrumentation (`-Cinstrument-coverage`) and profile-guided optimization (`-Cprofile-generate`, `-Cprofile-use`), which are unrelated and remain available.
-   Support for the target named `wasm32-wasi` has been removed as the target is now named `wasm32-wasip1`. This completes the [transition](https://redirect.github.com/rust-lang/compiler-team/issues/607) [plan](https://redirect.github.com/rust-lang/compiler-team/issues/695) for this target following [the introduction of `wasm32-wasip1`](https://redirect.github.com/rust-lang/rust/pull/120468) in Rust 1.78. Compiler warnings on [use of `wasm32-wasi`](https://redirect.github.com/rust-lang/rust/pull/126662) introduced in Rust 1.81 are now gone as well as the target is removed.
-   [The syntax `&pin (mut|const) T` is now parsed as a type which in theory could affect macro expansion results in some edge cases](https://redirect.github.com/rust-lang/rust/pull/130635#issuecomment-2375462821)
-   [Legacy syntax for calling `std::arch` functions is no longer permitted to declare items or bodies (such as closures, inline consts, or async blocks).](https://redirect.github.com/rust-lang/rust/pull/130443#issuecomment-2445678945)
-   The `wasm32-unknown-emscripten` target's binary release of the standard library is now [built with the latest emsdk 3.1.68](https://redirect.github.com/rust-lang/rust/pull/131533), which fixes an ABI-incompatibility with Emscripten >= 3.1.42. If you are locally using a version of emsdk with an incompatible ABI (e.g. before 3.1.42 or a future one), you should build your code with `-Zbuild-std` to ensure that `std` uses the correct ABI.
-   [Declaring functions with a calling convention not supported on the current target now triggers a hard error](https://redirect.github.com/rust-lang/rust/pull/129935)
-   [The next-generation trait solver is now enabled for coherence, fixing multiple soundness issues](https://redirect.github.com/rust-lang/rust/pull/130654)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - "before 11am on monday" in timezone Asia/Shanghai.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS45Mi4wIiwidXBkYXRlZEluVmVyIjoiMzkuOTIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
2025-01-09 18:11:17 +00:00
overlookmotel
0df18667ea fix(transformer/typescript): create Reference for require (#8355)
Create a `Reference` when generating new `IdentifierReference` for `require`.
2025-01-09 16:50:46 +00:00
Dunqing
79a8fc6f7d fix(semantic): report error for super property appearing in function body (#8376)
Missing error that super property inside plain function.

```js
class C {
  constructor() {
    function g() {
      // * It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true.
      super();
    }
  }
  method() {
    function func() {
      // It is a Syntax Error if FunctionBody Contains SuperProperty is true.
      super.good();
    }
  }
}
```

I am not sure why test262 doesn't cover tests like that
2025-01-09 06:38:09 +00:00
overlookmotel
f1f129b09d fix(transformer/private-methods): create brand binding var in hoist scope (#8361)
Brand binding is a `var`, so is bound in hoist scope.
2025-01-09 03:17:38 +00:00
翠 / green
3ba0b5316d
chore(tasks/coverage): fix test262 cases to run on windows (#8358)
`skip_test_path` was not working on windows because the path included
`\\`.
2025-01-09 10:48:37 +08:00
overlookmotel
78d7c97357 fix(transformer/typescript): create Reference for Infinity (#8354)
Create a `Reference` when generating new `IdentifierReference` for `Infinity`.
2025-01-09 02:26:33 +00:00
Dunqing
e4d66e4636 fix(transformer/arrow-functions): store super_methods on a Stack to fix nested async methods (#8331)
In the following case, async methods can be nested in another async method. The implementation is changing to store `super_methods` on a stack, and then we can store super method information in the correct `super_methods` map.

```js
const outer = {
  value: 0,
  async method() {
    () => super.value;

    const inner = {
      value: 0,
      async method() {
        () => super.value;
      }
    };

    () => super.value;
  }
};
```
2025-01-08 21:00:45 +00:00
Boshen
ce2b5a994b chore(minifier): disable RemoveUnusedCode (#8243)
A lot of edge cases fail in test262 and monitor-oxc.
2025-01-04 08:49:20 +00:00
Boshen
2da4365fbe feat(parser): missing initializer in destructuring declaration inside for loop head (#8222)
closes #8220
2025-01-02 14:02:49 +00:00
Boshen
2786dea164 feat(minifier): add RemoveUnusedCode (#8210) 2025-01-02 12:50:21 +00:00
Boshen
cd349a312d chore(tasks/coverage): do not run minifier in script mode (#8213) 2025-01-01 14:56:43 +00:00
Dunqing
e5ee38fdf1 chore(transformer): enable class-properties plugin (#7750)
Done!
2024-12-31 12:30:58 +00:00
branchseer
f88acb331b
fix(parser): allow line breaks between const and enum (#8193)
https://www.typescriptlang.org/play/?ts=5.7.2#code/MYewdgzgLgUApmArgWwAQEFUG8C+Mg
2024-12-31 08:45:17 +08:00
Boshen
11c4bd8687 feat(span): implement source type {file basename}.d.{extension}.ts (#8109) 2024-12-25 12:24:34 +00:00
camc314
708e9cfac0 fix(semantic): report errors for missing class method impls (#8082) 2024-12-25 12:24:33 +00:00
camc314
de82492e97 fix(parser): report syntax errors for missing constructor implementations (#8081) 2024-12-25 12:24:32 +00:00
injuly
55d6eb9507
fix(parser): disallow type parameters on class constructors (#8071)
TypeScript does not allow type parameters on constructors:

```ts
class A {
  constructor<T>(t: T) {} // <- should be an error
}
```

Here's a comparison snippet on:
1. [TypeScript
playground](https://www.typescriptlang.org/play/?#code/MYGwhgzhAECC0G8BQ1XWAewHYQC4CcBXYXDfAHlgD4AKASkSRTQF8kWg)
(syntax error).
2. [SWC
playground](https://play.swc.rs/?version=1.10.1&code=H4sIAAAAAAAAA0vOSSwuVnBWqOZSUEjOzysuKSpNLskvsgmx09BUqFao5aoFAOf92%2FAiAAAA&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BCIOhERP9mOVBTl7oUE0maH3xszsA5KwcwGnmotxzIkTYx0ziXhHER%2FSgKSE7IhmwRuvRWu1agd4x5tRwOiaUKpW8j3hoOLkbHjLfM22DH%2FC030iZD5ClZUh8nhVTc0Jfj4XvayfaQ%2B9tA%2F4Ad12XkxWH71TaEFh%2B0LYuVI0xQBAAA%3D)
(syntax error)
3. [OXC
playground](https://playground.oxc.rs/#eNo9T8EKwjAM/ZWSk8IOKngpInjxCzx66Wo2Cl0zkk4do/9u6+guyXshL+9lAQsarDci6qaWZ1DKUpDIk43El8d1t1+nSpWaniFBAwR6AZ5CaTKHaL6gswQb8C7EisXSiBuZh5Z8ZZFNkI54AN0ZL5gaGA0Lcr6YcblS8bb6H0A03GO2AJTT4XiGvGHphT2WMJkMLrjOVXH+JTL5u6dPEb+RW5KcaTVN6QerbleM)
(parses as valid syntax)

This PR makes OXC behave exactly like `tsc`, with a little test case.
Happy holidays!

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-24 07:38:39 +08:00
Boshen
e632a7b158 feat(transformer): remove typescript symbols after transform (#8069)
part of #7460
2024-12-23 08:24:54 +00:00
Boshen
be2c60dd10 fix(parser): parse import source from from 'mod' (#8056) 2024-12-21 10:20:14 +00:00
Boshen
8b025e36db chore(coverage): bump test262 (#8055) 2024-12-21 10:20:14 +00:00
camc314
274f117d4e fix(transformer/nullish-coalescing): use correct scope id for binding (#8053) 2024-12-21 07:08:29 +00:00
Dunqing
1cf7b83431 refactor(semantic): simplify handling namespace stack (#7987)
We had a BindingIdentifier to `TSModuleDeclarationName` so that we don't need to get binding from name.
2024-12-18 07:56:13 +00:00
Boshen
99a431be74
fix(coverage): make coverage runtime timeout stable (#7953)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-17 12:02:56 +08:00
Dunqing
14c51ffa1d fix(semantic): remove inherting ScopeFlags::Modifier from parent scope (#7932)
close: #7900

After #4283 changed, we don't need to inherit `ScopeFlags` from the `constructor`, `set`, `get` anymore, I think this is a logic of forgetting to remove
2024-12-16 11:26:12 +00:00
Dunqing
596aead0e9 fix(semantic): reset references flags when resolved (#7923)
For this case, we set `current_reference_flags` to `ReferenceFlags::Type` for `TSInterfaceHeritage`, but never unset it, which causes resolving `fowardRef` identifier reuse `current_reference_flags` of `TSInterfaceHeritage`.

```ts
import { forwardRef } from "react";
export interface MenuTriggerProps extends Object {}
export const MenuTrigger = forwardRef();
```

In this PR, reset the `current_reference_flags` when resolved, so that we don't need to reset it in individual visit functions. This is a reasonable change because the `current_reference_flags` only applies to the next encountered identifier.
2024-12-16 02:26:52 +00:00
翠 / green
db9e93b554
feat(mangler): mangle top level variables (#7907)
Adds `top_level` option which is similar to [terser's `toplevel`
option](https://terser.org/docs/cli-usage/#cli-mangle-options).

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-15 21:31:41 +08:00
overlookmotel
3858221f45 refactor(global): sort imports (#7883)
Pure refactor. Re-order imports for clarity:

1. `std`
2. External crates
3. `oxc_*` crates
4. Current crate `use crate::...`
5. Super `use super::...`
6. Local modules

This order is from "furthest away" to "closest". This makes it clearer to see what is coming from where.

`cargo +nightly fmt` (#7877) did a lot of the work, but unfortunately `rustfmt` does not have an option to (a) put workspace crates in a separate block from external crates and (b) move `mod` statements to after `use` statements.
2024-12-14 15:07:21 +00:00
Boshen
81eedb10c0 feat(parser): 'readonly' type modifier is only permitted on array and tuple literal types. (#7880) 2024-12-14 12:00:52 +00:00
Boshen
7fb9d47460 style(rust): cargo +nightly fmt (#7877) 2024-12-14 06:03:31 +00:00
Boshen
7610dc19ff fix(parser): parse import source from 'mod' (#7833) 2024-12-13 10:26:36 +00:00
Yunfei He
9479e2b0a2
fix(semantic): missing references when export {} references a type-only binding and a normal (#7812)
https://playground.oxc.rs/#eNpdTzEOgzAM/AryzFAqdUHq2rlD1YklUIMihTiyTQGh/L0BBEMn31l35/MCDZTQkBfNXmRE3xbHQKzZPSsqX3mcNrZkOgfcJU+mIPmfPEIOBOUCPPh1yOzVTFAqD5iDs14PLA0FPMnc1+QOpmy8tMT9vog5BMOCnAITXkMOfCq3BajhDtMFQLleihskRUMf7HDtkkhvvW3tYU7vKpN7OBpX8xe5JkmVWuMEY4w/P71iMw==

Current:

<img width="876" alt="image"
src="https://github.com/user-attachments/assets/58327920-44ef-469d-8c7c-a2d7b17da717"
/>


Expected:


https://babeljs.io/repl#?browsers=&build=&builtIns=false&corejs=false&spec=false&loose=false&code_lz=MYewdgzgLgBAKiAhtAagSwKYHcAOIBOsAvDAIwBQ5UAnjhvEtAAr4g4QwkXkYAeehGAG8YNOg2RQWbCABoJqTLgKwAvkA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Ctypescript&prettier=false&targets=&version=7.26.4&externalPlugins=&assumptions=%7B%7D

<img width="877" alt="image"
src="https://github.com/user-attachments/assets/9b847baa-5b5a-43be-b77d-d529fb3f8026"
/>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-12-13 12:00:58 +08:00
Dunqing
7a832307c2 fix(semantic): missing reference when export default references a type alias binding (#7813)
Fixes: #7809

`ExportNamedDecalration` and `ExportDefaultDeclaration` can reference both type binding and value, so we need to make sure the `ReferenceFlags` is `Read | Type`
2024-12-12 14:12:30 +00:00