mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Remove flag for enableEarlyReturnInReactiveScopes (always enable)
This commit is contained in:
@@ -273,16 +273,6 @@ const EnvironmentConfigSchema = z.object({
|
||||
*/
|
||||
enableEmitInstrumentForget: InstrumentationSchema.nullish(),
|
||||
|
||||
/**
|
||||
* Enable support for reactive scopes that contain an early return.
|
||||
* This is relatively infrequent, as reactive scopes generally span
|
||||
* up to but excluding return statements.
|
||||
*
|
||||
* When disabled, the compiler will error (bailout) on any functions which
|
||||
* would create a reactive scope that contains a return statement.
|
||||
*/
|
||||
enableEarlyReturnInReactiveScopes: z.boolean().default(true),
|
||||
|
||||
// Enable validation of mutable ranges
|
||||
assertValidMutableRanges: z.boolean().default(false),
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { visitReactiveFunction } from ".";
|
||||
import { CompilerError, Effect } from "..";
|
||||
import { Effect } from "..";
|
||||
import {
|
||||
Environment,
|
||||
GeneratedSource,
|
||||
@@ -266,14 +266,6 @@ class Transform extends ReactiveFunctionTransform<State> {
|
||||
state: State
|
||||
): Transformed<ReactiveStatement> {
|
||||
if (state.withinReactiveScope && stmt.terminal.kind === "return") {
|
||||
if (!this.env.config.enableEarlyReturnInReactiveScopes) {
|
||||
CompilerError.throwTodo({
|
||||
reason: `Support early return within a reactive scope`,
|
||||
loc: stmt.terminal.value.loc,
|
||||
description: null,
|
||||
suggestions: null,
|
||||
});
|
||||
}
|
||||
const loc = stmt.terminal.value.loc;
|
||||
let earlyReturnValue: ReactiveScope["earlyReturnValue"];
|
||||
if (state.earlyReturnValue !== null) {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableEarlyReturnInReactiveScopes:false
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
if (props.cond) {
|
||||
x.push(props.a);
|
||||
// oops no memo!
|
||||
return x;
|
||||
} else {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ cond: true, a: 42 }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
5 | x.push(props.a);
|
||||
6 | // oops no memo!
|
||||
> 7 | return x;
|
||||
| ^ Todo: Support early return within a reactive scope (7:7)
|
||||
8 | } else {
|
||||
9 | return foo();
|
||||
10 | }
|
||||
```
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// @enableEarlyReturnInReactiveScopes:false
|
||||
function Component(props) {
|
||||
let x = [];
|
||||
if (props.cond) {
|
||||
x.push(props.a);
|
||||
// oops no memo!
|
||||
return x;
|
||||
} else {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ cond: true, a: 42 }],
|
||||
};
|
||||
Reference in New Issue
Block a user