mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Update hoisting error message to allow error aggregation
Interpolating values into the `reason` field of an error breaks our error aggregation. This PR moves the offending function name into the `description` field which isn't used for aggregation.
This commit is contained in:
@@ -646,9 +646,8 @@ function checkFunctionReferencedBeforeDeclarationAtTopLevel(
|
||||
if (scope === null) {
|
||||
errors.pushErrorDetail(
|
||||
new CompilerErrorDetail({
|
||||
reason: `Encountered ${fn.name} used before declaration which breaks Forget's gating codegen due to hoisting`,
|
||||
description:
|
||||
"Rewrite the reference to not use hoisting to fix this issue",
|
||||
reason: `Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting`,
|
||||
description: `Rewrite the reference to ${fn.name} to not rely on hoisting to fix this issue`,
|
||||
loc: fn.loc ?? null,
|
||||
suggestions: null,
|
||||
severity: ErrorSeverity.Invariant,
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ component Foo(ref: React.RefSetter<Controls>) {
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Invariant: Encountered Foo_withRef used before declaration which breaks Forget's gating codegen due to hoisting. Rewrite the reference to not use hoisting to fix this issue (2:2)
|
||||
[ReactForget] Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Foo_withRef to not rely on hoisting to fix this issue (2:2)
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ function Foo_withRef(props, ref) {
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Invariant: Encountered Foo_withRef used before declaration which breaks Forget's gating codegen due to hoisting. Rewrite the reference to not use hoisting to fix this issue (3:3)
|
||||
[ReactForget] Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Foo_withRef to not rely on hoisting to fix this issue (3:3)
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ function Foo() {}
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] Invariant: Encountered Foo used before declaration which breaks Forget's gating codegen due to hoisting. Rewrite the reference to not use hoisting to fix this issue (5:5)
|
||||
[ReactForget] Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Foo to not rely on hoisting to fix this issue (5:5)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user