Skip to content

fix(react-compiler): keep the optional chain through a non-null assertion - #28144

Merged
Dunqing merged 2 commits into
oxc-project:mainfrom
sarankumar1325:fix/react-compiler-optional-non-null
Oct 26, 2026
Merged

Dunqing merged 2 commits into
oxc-project:mainfrom
sarankumar1325:fix/react-compiler-optional-non-null

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Fixes #28142

Before / After

users?.find((user) => user.id === userId)!.name

Before: users.find((user) => user.id === userId).name (the ?. was dropped, so this throws when users is undefined)
After: users?.find((user) => user.id === userId).name

Cause

In oxc the whole chain is one ChainExpression, and the lowering decides whether a member or call is optional by walking its receiver spine (expr_contains_optional). A TSNonNullExpression stopped that walk, and the other arm in the optional member/call lowering then lowered it as a plain expression. Babel keeps the chain going through !, so the inner link should still be an optional member/call.

Fix

  • expr_contains_optional looks through TSNonNullExpression.
  • When the object of an optional member, or the callee of an optional call, is a TSNonNullExpression, it is lowered with lower_chain_subexpr so the inner link keeps its optional semantics.

Tests

  • New fixtures optional-chain-non-null-assertion.tsx (the issue repro) and optional-chain-non-null-assertion-call.tsx (obj?.get!().value and obj?.get?.()!.value), with snapshots.
  • cargo test -p oxc_react_compiler passes with no changes to existing snapshots; cargo clippy -p oxc_react_compiler --all-targets -- -D warnings and cargo fmt are clean.

AI disclosure: this change was written with help from an AI assistant and reviewed and tested by me.

…tion

A non-null assertion inside an optional chain (`a?.b()!.c`, `a?.b!()`) was
lowered as a plain expression, so the inner `?.` was dropped from the output.
Treat `TSNonNullExpression` as part of the chain, matching Babel's AST.

Fixes oxc-project#28142
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T14:47:30.149309Z 0e82b4a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the A-react-compiler Area - React Compiler transforms and lint rules, oxc_react_compiler label Oct 24, 2026
@codspeed

codspeed Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 86 skipped benchmarks1


Comparing sarankumar1325:fix/react-compiler-optional-non-null (7d27448) with main (a22c9f2)

Open in CodSpeed

Footnotes

  1. 86 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@dvd900

dvd900 commented Oct 24, 2026

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e82b4a254

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Dunqing
Dunqing merged commit f32a8d8 into oxc-project:main Oct 26, 2026
35 checks passed
Dunqing added a commit that referenced this pull request Oct 26, 2026
Memoization can hide a required `TypeError` after an optional chain
short-circuits on an earlier render. For `obj?.a.b(getArg())`, rendering
first with `obj = undefined` caches `undefined`; rendering again with
`obj = {}` can reuse that result because the reduced dependency `obj?.a`
is still `undefined`. The second render should throw when reading `.b`.

Keep non-optional continuation dependencies below optional prefixes
instead of letting the prefix subsume them. When a computed or call
continuation cannot be represented as a property path, retain the
original optional guard dependency. For conditionally evaluated chains
such as `getArg() ? obj?.a.b(getArg()) : null`, truncate an unhoistable
dependency before its last optional link. This tracks the guard without
moving a throwing read ahead of its condition. Fully optional chains
keep their existing dependency reduction.

Adds 11 focused Node runtime cases comparing compiled and original
JavaScript over two consecutive renders, with truthy and falsy
conditions. They cover static, computed, optional-call, nested,
conditional, and fully optional chains, plus method receivers. Output
snapshots cover the generated dependencies.

This bug predates and is independent of
#28144. The same static,
computed, and optional-call failures were reproduced with
`babel-plugin-react-compiler@1.0.0` and `@babel/core@8.0.9`; this
intentionally corrects behavior also present upstream.

Validation:
- `cargo +1.99.1 test -p oxc_react_compiler --all-features`: 18 unit
tests, 26 integration tests, and the full snapshot suite passed.
- `cargo +1.99.1 clippy -p oxc_react_compiler --all-targets
--all-features -- -D warnings` passed.
- `cargo +1.99.1 fmt -p oxc_react_compiler -- --check` and `git diff
--check` passed.
- An additional local differential matrix of 73 expressions and 18,688
render transitions passed with no skipped compilations.
- NAPI binding tests were not run locally.

AI assistance: the implementation, regression tests, and PR description
were prepared with AI assistance.
acusti added a commit to acusti/uikit that referenced this pull request Oct 27, 2026
Exact pin in @acusti/vite-plugin-react-compiler, plus the root and docs
devDependency ranges so bun hoists a single copy.

Exhaustive manual memoization validation is now on by default
(validateExhaustiveMemoizationDependencies, oxc-project/oxc#28101), as
on React Compiler main: a component or hook whose useMemo or useCallback
dependency list is missing a dependency or lists an extra one is skipped.
0.155.0 and babel-plugin-react-compiler@1.0.0 compile it with the
dependencies they infer, which changes when the value updates. The
plugin keeps the upstream default. The README documents the bail-out
and how to turn the check off, and qualifies its claim that the port
compiles a superset of what the Babel plugin compiles.

The release also fixes compiled output for:
- an optional chain continued through a non-null assertion
  (`users?.find(…)!.name`), which lost its `?.` (oxc-project/oxc#28144)
- a value that a branch inside `try` picks from props, or that `catch`
  assigns when a prop makes `try` throw, which was cached once per mount
  (oxc-project/oxc#27817, oxc-project/oxc#28005)
- a `try` whose `catch` can never run, which panicked and aborted the
  process, or compiled the component to an empty function
  (oxc-project/oxc#28066)
- optional-chain dependencies, which keep the reads after an optional
  link, so a cached value no longer hides a TypeError the uncompiled
  code throws (oxc-project/oxc#28165)
- JSX outlining (opt-in `enableJsxOutlining`), which emitted invalid
  destructuring for hyphenated props like `aria-label`
  (oxc-project/oxc#28111)

Every JS/TS file in the repo compiles to identical code and diagnostics
on 0.155.0 and 0.156.0 (default and `compilationMode: 'all'`); the
source maps of Dropdown.tsx and helpers.ts differ only in the `names`
label of an optional-chain dependency. So do 9,706 TS/TSX/JSX files and
a 4,000-file JS sample from this repo’s dependencies (compiled under a
path outside node_modules), apart from five files in
`compilationMode: 'all'` whose differences come from
oxc-project/oxc#28165 and oxc-project/oxc#28005. No function changes
whether it compiles, and the public typings differ only in the
validateExhaustiveMemoizationDependencies default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 27, 2026
A compiled component printed `users?.find(…)!.name` as
`users.find(…).name` through 0.155.0, which throws while `users` is
undefined; kept as of 0.156.0 (oxc-project/oxc#28144), as
babel-plugin-react-compiler@1.0.0 does. The test fails against 0.155.0
and passes against 0.156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 27, 2026
Exact pin in @acusti/vite-plugin-react-compiler, plus the root and docs
devDependency ranges so bun hoists a single copy.

Exhaustive manual memoization validation is now on by default
(validateExhaustiveMemoizationDependencies, oxc-project/oxc#28101), as
on React Compiler main: a component or hook whose useMemo or useCallback
dependency list is missing a dependency or lists an extra one is skipped.
0.155.0 and babel-plugin-react-compiler@1.0.0 compile it with the
dependencies they infer, which changes when the value updates. The
plugin keeps the upstream default. The README documents the bail-out
and how to turn the check off, and qualifies its claim that the port
compiles a superset of what the Babel plugin compiles.

The release also fixes compiled output for:
- an optional chain continued through a non-null assertion
  (`users?.find(…)!.name`), which lost its `?.` (oxc-project/oxc#28144)
- a value that a branch inside `try` picks from props, or that `catch`
  assigns when a prop makes `try` throw, which was cached once per mount
  (oxc-project/oxc#27817, oxc-project/oxc#28005)
- a `try` whose `catch` can never run, which panicked and aborted the
  process, or compiled the component to an empty function
  (oxc-project/oxc#28066)
- optional-chain dependencies, which keep the reads after an optional
  link, so a cached value no longer hides a TypeError the uncompiled
  code throws (oxc-project/oxc#28165)
- JSX outlining (opt-in `enableJsxOutlining`), which emitted invalid
  destructuring for hyphenated props like `aria-label`
  (oxc-project/oxc#28111)

Every JS/TS file in the repo compiles to identical code and diagnostics
on 0.155.0 and 0.156.0 (default and `compilationMode: 'all'`); the
source maps of Dropdown.tsx and helpers.ts differ only in the `names`
label of an optional-chain dependency. So do 9,706 TS/TSX/JSX files and
a 4,000-file JS sample from this repo’s dependencies (compiled under a
path outside node_modules), apart from five files in
`compilationMode: 'all'` whose differences come from
oxc-project/oxc#28165 and oxc-project/oxc#28005. No function changes
whether it compiles, and the public typings differ only in the
validateExhaustiveMemoizationDependencies default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 27, 2026
A compiled component printed `users?.find(…)!.name` as
`users.find(…).name` through 0.155.0, which throws while `users` is
undefined; kept as of 0.156.0 (oxc-project/oxc#28144), as
babel-plugin-react-compiler@1.0.0 does. The test fails against 0.155.0
and passes against 0.156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 28, 2026
Exact pin in @acusti/vite-plugin-react-compiler, plus the root and docs
devDependency ranges so bun hoists a single copy.

Exhaustive manual memoization validation is now on by default
(validateExhaustiveMemoizationDependencies, oxc-project/oxc#28101), as
on React Compiler main: a component or hook whose useMemo or useCallback
dependency list is missing a dependency or lists an extra one is skipped.
0.155.0 and babel-plugin-react-compiler@1.0.0 compile it with the
dependencies they infer, which changes when the value updates. The
plugin keeps the upstream default. With panicThreshold set to
'critical_errors' or 'all_errors', the new diagnostic fails the build.
The changeset and README document the bail-out, that build failure,
reportDiagnostics to find the skipped components, and how to turn the
check off. The README also notes that its production result still
holds: the same functions in that app compile on 0.155.0 and 0.156.0.

The release also fixes compiled output for:
- an optional chain continued through a non-null assertion
  (`users?.find(…)!.name`), which lost its `?.` (oxc-project/oxc#28144)
- a value that a branch inside `try` picks from props, or that `catch`
  assigns when a prop makes `try` throw, which was cached once per mount
  (oxc-project/oxc#27817, oxc-project/oxc#28005)
- a `try` whose `catch` can never run, which panicked and aborted the
  process, or compiled the component to an empty function
  (oxc-project/oxc#28066)
- optional-chain dependencies, which keep the reads after an optional
  link, so a cached value no longer hides a TypeError the uncompiled
  code throws (oxc-project/oxc#28165)
- JSX outlining (opt-in `enableJsxOutlining`), which emitted invalid
  destructuring for hyphenated props like `aria-label`
  (oxc-project/oxc#28111)

Every JS/TS file in the repo compiles to identical code and diagnostics
on 0.155.0 and 0.156.0 (default and `compilationMode: 'all'`); the
source maps of Dropdown.tsx and helpers.ts differ only in the `names`
label of an optional-chain dependency. So do 9,706 TS/TSX/JSX files and
a 4,000-file JS sample from this repo’s dependencies (compiled under a
path outside node_modules), apart from five files in
`compilationMode: 'all'` whose differences come from
oxc-project/oxc#28165 and oxc-project/oxc#28005. No function changes
whether it compiles, and the public typings differ only in the
validateExhaustiveMemoizationDependencies default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 28, 2026
A compiled component printed `users?.find(…)!.name` as
`users.find(…).name` through 0.155.0, which throws while `users` is
undefined; kept as of 0.156.0 (oxc-project/oxc#28144), as
babel-plugin-react-compiler@1.0.0 does. The test fails against 0.155.0
and passes against 0.156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 28, 2026
Exact pin in @acusti/vite-plugin-react-compiler, plus the root and docs
devDependency ranges so bun hoists a single copy.

Exhaustive manual memoization validation is now on by default
(validateExhaustiveMemoizationDependencies, oxc-project/oxc#28101), as
on React Compiler main: a component or hook whose useMemo or useCallback
dependency list is missing a dependency or lists an extra one is skipped.
0.155.0 and babel-plugin-react-compiler@1.0.0 compile it with the
dependencies they infer, which changes when the value updates. The
plugin keeps the upstream default. With panicThreshold set to
'critical_errors' or 'all_errors', the new diagnostic fails the build.
The changeset and README document the bail-out, that build failure,
reportDiagnostics to find the skipped components, and how to turn the
check off. The README also notes that its production result still
holds: the same functions in that app compile on 0.155.0 and 0.156.0.

The release also fixes compiled output for:
- an optional chain continued through a non-null assertion
  (`users?.find(…)!.name`), which lost its `?.` (oxc-project/oxc#28144)
- a value that a branch inside `try` picks from props, or that `catch`
  assigns when a prop makes `try` throw, which was cached once per mount
  (oxc-project/oxc#27817, oxc-project/oxc#28005)
- a `try` whose `catch` can never run, which panicked and aborted the
  process, or compiled the component to an empty function
  (oxc-project/oxc#28066)
- optional-chain dependencies, which keep the reads after an optional
  link, so a cached value no longer hides a TypeError the uncompiled
  code throws (oxc-project/oxc#28165)
- JSX outlining (opt-in `enableJsxOutlining`), which emitted invalid
  destructuring for hyphenated props like `aria-label`
  (oxc-project/oxc#28111)

Every JS/TS file in the repo compiles to identical code and diagnostics
on 0.155.0 and 0.156.0 (default and `compilationMode: 'all'`); the
source maps of Dropdown.tsx and helpers.ts differ only in the `names`
label of an optional-chain dependency. So do 9,706 TS/TSX/JSX files and
a 4,000-file JS sample from this repo’s dependencies (compiled under a
path outside node_modules), apart from five files in
`compilationMode: 'all'` whose differences come from
oxc-project/oxc#28165 and oxc-project/oxc#28005. No function changes
whether it compiles, and the public typings differ only in the
validateExhaustiveMemoizationDependencies default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 28, 2026
A compiled component printed `users?.find(…)!.name` as
`users.find(…).name` through 0.155.0, which throws while `users` is
undefined; kept as of 0.156.0 (oxc-project/oxc#28144), as
babel-plugin-react-compiler@1.0.0 does. The test fails against 0.155.0
and passes against 0.156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 28, 2026
Exact pin in @acusti/vite-plugin-react-compiler, plus the root and docs
devDependency ranges so bun hoists a single copy.

Exhaustive manual memoization validation is now on by default
(validateExhaustiveMemoizationDependencies, oxc-project/oxc#28101), as
on React Compiler main: a component or hook whose useMemo or useCallback
dependency list is missing a dependency or lists an extra one is skipped.
0.155.0 and babel-plugin-react-compiler@1.0.0 compile it with the
dependencies they infer, which changes when the value updates. The
plugin keeps the upstream default. With panicThreshold set to
'critical_errors' or 'all_errors', the new diagnostic fails the build.
The changeset and README document the bail-out, that build failure,
reportDiagnostics to find the skipped components, and how to turn the
check off. The README’s caveats section now says the port differs from
the Babel plugin in both directions (compiling some code the Babel
plugin bails on, skipping these functions it compiles), and dates the
production results to the bindings they were measured on, 0.142.0,
instead of claiming parity in the present tense.

The release also fixes compiled output for:
- an optional chain continued through a non-null assertion
  (`users?.find(…)!.name`), which lost its `?.` (oxc-project/oxc#28144)
- a value that a branch inside `try` picks from props, or that `catch`
  assigns when a prop makes `try` throw, which was cached once per mount
  (oxc-project/oxc#27817, oxc-project/oxc#28005)
- a `try` whose `catch` can never run, which panicked and aborted the
  process, or compiled the component to an empty function
  (oxc-project/oxc#28066)
- optional-chain dependencies, which keep the reads after an optional
  link, so a cached value no longer hides a TypeError the uncompiled
  code throws (oxc-project/oxc#28165)
- JSX outlining (opt-in `enableJsxOutlining`), which emitted invalid
  destructuring for hyphenated props like `aria-label`
  (oxc-project/oxc#28111)

Every JS/TS file in the repo compiles to identical code and diagnostics
on 0.155.0 and 0.156.0 (default and `compilationMode: 'all'`); the
source maps of Dropdown.tsx and helpers.ts differ only in the `names`
label of an optional-chain dependency. So do 9,706 TS/TSX/JSX files and
a 4,000-file JS sample from this repo’s dependencies (compiled under a
path outside node_modules), apart from five files in
`compilationMode: 'all'` whose differences come from
oxc-project/oxc#28165 and oxc-project/oxc#28005. No function changes
whether it compiles, and the public typings differ only in the
validateExhaustiveMemoizationDependencies default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 28, 2026
A compiled component printed `users?.find(…)!.name` as
`users.find(…).name` through 0.155.0, which throws while `users` is
undefined; kept as of 0.156.0 (oxc-project/oxc#28144), as
babel-plugin-react-compiler@1.0.0 does. The test fails against 0.155.0
and passes against 0.156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 29, 2026
Exact pin in @acusti/vite-plugin-react-compiler, plus the root and docs
devDependency ranges so bun hoists a single copy.

Exhaustive manual memoization validation is on by default again
(validateExhaustiveMemoizationDependencies, oxc-project/oxc#28101), as
on React Compiler main: a component or hook whose useMemo or useCallback
dependency list is missing a dependency or lists an extra one is skipped.
It was on at 0.142.0, the plugin’s first pinned version, and off from
0.144.0 through 0.155.0.
0.155.0 and babel-plugin-react-compiler@1.0.0 compile it with the
dependencies they infer, which changes when the value updates. The
plugin keeps the upstream default. With panicThreshold set to
'critical_errors' or 'all_errors', the new diagnostic fails the build.
The changeset and README document the bail-out, that build failure,
reportDiagnostics to find the skipped components, and how to turn the
check off. The README’s caveats section now says the port differs from
the Babel plugin in both directions (compiling some code the Babel
plugin bails on, skipping these functions it compiles), and dates the
production results to the bindings they were measured on, 0.142.0,
instead of claiming parity in the present tense.

The release also fixes compiled output for:
- an optional chain continued through a non-null assertion
  (`users?.find(…)!.name`), which lost its `?.` (oxc-project/oxc#28144)
- a value that a branch inside `try` picks from props, or that `catch`
  assigns when a prop makes `try` throw, which was cached once per mount
  (oxc-project/oxc#27817, oxc-project/oxc#28005)
- a `try` whose `catch` can never run, which panicked and aborted the
  process, or compiled the component to an empty function
  (oxc-project/oxc#28066)
- optional-chain dependencies, which keep the reads after an optional
  link, so a cached value no longer hides a TypeError the uncompiled
  code throws (oxc-project/oxc#28165)
- JSX outlining (opt-in `enableJsxOutlining`), which emitted invalid
  destructuring for hyphenated props like `aria-label`
  (oxc-project/oxc#28111)

Every JS/TS file in the repo compiles to identical code and diagnostics
on 0.155.0 and 0.156.0 (default and `compilationMode: 'all'`); the
source maps of Dropdown.tsx and helpers.ts differ only in the `names`
label of an optional-chain dependency. So do 9,706 TS/TSX/JSX files and
a 4,000-file JS sample from this repo’s dependencies (compiled under a
path outside node_modules), apart from five files in
`compilationMode: 'all'` whose differences come from
oxc-project/oxc#28165 and oxc-project/oxc#28005. No function changes
whether it compiles, and the public typings differ only in the
validateExhaustiveMemoizationDependencies default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 29, 2026
A compiled component printed `users?.find(…)!.name` as
`users.find(…).name` through 0.155.0, which throws while `users` is
undefined; kept as of 0.156.0 (oxc-project/oxc#28144), as
babel-plugin-react-compiler@1.0.0 does. The test fails against 0.155.0
and passes against 0.156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 29, 2026
Exact pin in @acusti/vite-plugin-react-compiler, plus the root and docs
devDependency ranges so bun hoists a single copy.

Exhaustive manual memoization validation is on by default again
(validateExhaustiveMemoizationDependencies, oxc-project/oxc#28101), as
on React Compiler main: a component or hook whose useMemo or useCallback
dependency list is missing a dependency or lists an extra one is skipped.
It was on at 0.142.0, the plugin’s first pinned version, and off from
0.144.0 through 0.155.0.
0.155.0 and babel-plugin-react-compiler@1.0.0 compile it with the
dependencies they infer, which changes when the value updates. The
plugin keeps the upstream default. With panicThreshold set to
'critical_errors' or 'all_errors', the new diagnostic fails the build.
The changeset and README document the bail-out, that build failure,
reportDiagnostics to find the skipped components, and how to turn the
check off. The README’s caveats section now says the port differs from
the Babel plugin in both directions (compiling some code the Babel
plugin bails on, skipping these functions it compiles), and dates the
production results to the bindings they were measured on, 0.142.0,
instead of claiming parity in the present tense.

The release also fixes compiled output for:
- an optional chain continued through a non-null assertion
  (`users?.find(…)!.name`), which lost its `?.` (oxc-project/oxc#28144)
- a value that a branch inside `try` picks from props, or that `catch`
  assigns when a prop makes `try` throw, which was cached once per mount
  (oxc-project/oxc#27817, oxc-project/oxc#28005)
- a `try` whose `catch` can never run, which panicked and aborted the
  process, or compiled the component to an empty function
  (oxc-project/oxc#28066)
- optional-chain dependencies, which keep the reads after an optional
  link, so a cached value no longer hides a TypeError the uncompiled
  code throws (oxc-project/oxc#28165)
- JSX outlining (opt-in `enableJsxOutlining`), which emitted invalid
  destructuring for hyphenated props like `aria-label`
  (oxc-project/oxc#28111)

Every JS/TS file in the repo compiles to identical code and diagnostics
on 0.155.0 and 0.156.0 (default and `compilationMode: 'all'`); the
source maps of Dropdown.tsx and helpers.ts differ only in the `names`
label of an optional-chain dependency. So do 9,706 TS/TSX/JSX files and
a 4,000-file JS sample from this repo’s dependencies (compiled under a
path outside node_modules), apart from five files in
`compilationMode: 'all'` whose differences come from
oxc-project/oxc#28165 and oxc-project/oxc#28005. No function changes
whether it compiles, and the public typings differ only in the
validateExhaustiveMemoizationDependencies default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acusti added a commit to acusti/uikit that referenced this pull request Oct 29, 2026
A compiled component printed `users?.find(…)!.name` as
`users.find(…).name` through 0.155.0, which throws while `users` is
undefined; kept as of 0.156.0 (oxc-project/oxc#28144), as
babel-plugin-react-compiler@1.0.0 does. The test fails against 0.155.0
and passes against 0.156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-react-compiler Area - React Compiler transforms and lint rules, oxc_react_compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

react-compiler: a?.b!.c compiles to a.b.c, dropping the optional chain

3 participants