mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
0eac5a0373
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.
9 lines
165 B
TypeScript
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;
|
|
}
|
|
}
|