Add new ErrorSeverity.CannotPreserveMemoization
This adds a new category of error where the compiler cannot preserve memoization exactly how as it was originally authored. We're adding a new category here because it's not an actionable error, and allows us to more specifically control whether it's reportable or not. ghstack-source-id: 9693cd42ca64b980248c6202091bdd4c827e1cd4 Pull Request resolved: https://github.com/facebook/react-forget/pull/2824
Lauren Tan committed
Apr 8, 2024 at 10:55 UTC
1f35f7e320bd2f75421a7d4b0b13cf2a7604a980
2 files changed
+4
compiler/packages/babel-plugin-react-forget/src/CompilerError.ts
+3
@@ -15,6 +15,8 @@ export enum ErrorSeverity {
15
InvalidReact = "InvalidReact",
16
// Incorrect configuration of the compiler.
17
InvalidConfig = "InvalidConfig",
18
+ // Code that can reasonably occur and that doesn't break any rules, but is unsafe to perserve memoization.
19
+ CannotPreserveMemoization = "CannotPreserveMemoization",
20
// Unhandled syntax that we don't support yet.
21
Todo = "Todo",
22
/*
@@ -219,6 +221,7 @@ export class CompilerError extends Error {
221
case ErrorSeverity.InvalidReact:
222
case ErrorSeverity.InvalidConfig:
223
return true;
224
+ case ErrorSeverity.CannotPreserveMemoization:
225
case ErrorSeverity.Todo:
226
return false;
227
default:
compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
+1
@@ -44,6 +44,7 @@ function isReportableDiagnostic(
44
break;
45
case ErrorSeverity.InvalidConfig:
46
case ErrorSeverity.Invariant:
47
+ case ErrorSeverity.CannotPreserveMemoization:
48
case ErrorSeverity.Todo:
49
break;
50
default: