mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Distinguish error fixtures for invalid code
Renames some error fixtures for clarity, "error.invalid-*" are fixtures that are expected to fail for invalid input, where other "error.*" fixtures are basically todos. While i was here i clarified the error messages for invalid useMemo callbacks, and changes the error severity from Invariant to InvalidInput.
This commit is contained in:
@@ -100,15 +100,15 @@ export function inlineUseMemo(fn: HIRFunction): void {
|
||||
}
|
||||
|
||||
if (body.loweredFunc.params.length > 0) {
|
||||
CompilerError.invariant(
|
||||
"Did not expect any arguments to useMemo callback",
|
||||
CompilerError.invalidInput(
|
||||
"useMemo callbacks may not accept any arguments",
|
||||
body.loc
|
||||
);
|
||||
}
|
||||
|
||||
if (body.loweredFunc.async || body.loweredFunc.generator) {
|
||||
CompilerError.invariant(
|
||||
"Did not expect useMemo callback to be async or a generator",
|
||||
CompilerError.invalidInput(
|
||||
"useMemo callbacks may not be async or generator functions",
|
||||
body.loc
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ function component(a, b) {
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Invariant: Did not expect useMemo callback to be async or a generator (2:4)
|
||||
[ReactForget] InvalidInput: useMemo callbacks may not be async or generator functions (2:4)
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ function component(a, b) {
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Invariant: Did not expect any arguments to useMemo callback (2:2)
|
||||
[ReactForget] InvalidInput: useMemo callbacks may not accept any arguments (2:2)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user