Versions: oxc-transform@0.127.0 (also oxc-parser@0.127.0), Node v24
import {transformSync} from "oxc-transform";
const src = `const x = a[b?.c!]?.["d"];`;
transformSync("repro.ts", src, {lang: "ts", target: ["es2018"]});
Results in
thread '<unnamed>' panicked at crates/oxc_ast/src/ast/js.rs:1085:1:
called `Option::unwrap()` on a `None` value
Trigger conditions (all required):
- TS non-null assertion (!) on an expression containing ?.,
- used as a computed (bracket) member key,
- the surrounding expression is itself an optional chain (obj[…]?.member),
- target lowers optional chaining (any < ES2020 / Safari < 14 / Chrome < 80, etc.).
Workarounds (each avoids the panic):
- drop the !: a[b?.c]?.["d"]
- non-optional outer access: a[b?.c!]["d"]
- parenthesize inner: a[(b?.c)!]?.["d"]
- target: "esnext" (no lowering)
Versions: oxc-transform@0.127.0 (also oxc-parser@0.127.0), Node v24
Results in
Trigger conditions (all required):
Workarounds (each avoids the panic):