mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Some existing InvalidConfig errors should be invariants
Now that we have validation of the compiler config, these old errors weren't categorized correctly. Readjusted them to be invariants instead.
This commit is contained in:
1 parent
973ec414bd
commit
bb92520ba5
4 files changed
+14
-15
No files matched your search
@@ -23,22 +23,21 @@ export function addImportsToProgram(
|
||||
* Codegen currently does not rename import specifiers, so we do additional
|
||||
* validation here
|
||||
*/
|
||||
if (identifiers.has(importSpecifierName)) {
|
||||
CompilerError.throwInvalidConfig({
|
||||
reason: `Encountered conflicting import specifier for ${importSpecifierName} in Forget config.`,
|
||||
description: null,
|
||||
loc: GeneratedSource,
|
||||
suggestions: null,
|
||||
});
|
||||
}
|
||||
if (path.scope.hasBinding(importSpecifierName)) {
|
||||
CompilerError.throwInvalidConfig({
|
||||
CompilerError.invariant(identifiers.has(importSpecifierName) === false, {
|
||||
reason: `Encountered conflicting import specifier for ${importSpecifierName} in Forget config.`,
|
||||
description: null,
|
||||
loc: GeneratedSource,
|
||||
suggestions: null,
|
||||
});
|
||||
CompilerError.invariant(
|
||||
path.scope.hasBinding(importSpecifierName) === false,
|
||||
{
|
||||
reason: `Encountered conflicting import specifiers for ${importSpecifierName} in generated program.`,
|
||||
description: null,
|
||||
loc: GeneratedSource,
|
||||
suggestions: null,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
identifiers.add(importSpecifierName);
|
||||
|
||||
const importSpecifierNameList = getOrInsertDefault(
|
||||
|
||||
@@ -666,7 +666,7 @@ function checkFunctionReferencedBeforeDeclarationAtTopLevel(
|
||||
"Rewrite the reference to not use hoisting to fix this issue",
|
||||
loc: fn.loc ?? null,
|
||||
suggestions: null,
|
||||
severity: ErrorSeverity.InvalidConfig,
|
||||
severity: ErrorSeverity.Invariant,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ function useFoo(props) {
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] InvalidConfig: Encountered conflicting import specifiers for makeReadOnly in generated program.
|
||||
[ReactForget] Invariant: Encountered conflicting import specifiers for makeReadOnly in generated program.
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ function Foo() {}
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] InvalidConfig: 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 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)
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user