Files
oxc-project__oxc/crates/oxc_react_compiler/fixtures/try-catch-property-dependency.tsx
Boshen 0eac5a0373 fix(react_compiler): preserve caught throw semantics (#25593)
Preserve potentially throwing operations inside try/catch when dead-code elimination would otherwise remove their unused results. Share the throw classifier with try-edge pruning, retain caught destructuring, and use safe root dependencies without hoisting throwing operations outside their handlers.

This preserves source runtime behavior for property and computed reads, coercions, destructuring, computed keys, and spreads. Latest React Compiler currently has the same DCE divergence, so this follows JavaScript semantics rather than its incorrect output.

Validated with `just ready` and React Compiler’s Sprout evaluator.

AI assistance was used to investigate and implement this change.
2026-08-13 15:54:06 +00:00

9 lines
165 B
TypeScript

function Component({name}: {name: string}) {
try {
const url = new URL(name);
return <div>{url.search}{url.hash}</div>;
} catch {
return null;
}
}