diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Suppression.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Suppression.ts index 78e2020b37..815def3735 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Suppression.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Suppression.ts @@ -13,6 +13,7 @@ import { CompilerSuggestionOperation, ErrorSeverity, } from "../CompilerError"; +import { assertExhaustive } from "../Utils/utils"; /** * Captures the start and end range of a pair of eslint-disable ... eslint-enable comments. In the @@ -170,6 +171,12 @@ export function suppressionsToCompilerError( reason = "React Forget has bailed out of optimizing this component as one or more React rule violations were reported by Flow"; suggestion = "Remove the Flow suppression and address the React error"; + break; + default: + assertExhaustive( + suppressionRange.source, + "Unhandled suppression source" + ); } error.pushErrorDetail( new CompilerErrorDetail({ diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bailout-on-flow-suppression.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bailout-on-flow-suppression.expect.md index d1cbeaff62..1642c6aa22 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bailout-on-flow-suppression.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bailout-on-flow-suppression.expect.md @@ -5,9 +5,9 @@ // @enableFlowSuppressions function Foo(props) { - // $FlowFixMe[react-rule-hook] - useX(); - return null; + // $FlowFixMe[react-rule-hook] + useX(); + return null; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.expect.md index 4b2b5633e7..a4b008a71c 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.expect.md @@ -5,12 +5,22 @@ // @enableFlowSuppressions function Foo(props) { - // $FlowFixMe[incompatible-type] - useX(); - const x = new Foo(...props.foo, null, ...[props.bar]); - return x; + // $FlowFixMe[incompatible-type] + useX(); + const x = new Foo(...props.foo, null, ...[props.bar]); + return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Foo, + params: [ + { + foo: [1], + bar: 2, + }, + ], +}; + ``` ## Code @@ -35,5 +45,15 @@ function Foo(props) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Foo, + params: [ + { + foo: [1], + bar: 2, + }, + ], +}; + ``` \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.js index c5c3fd5295..87394f5335 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/no-flow-bailout-unrelated.js @@ -6,3 +6,13 @@ function Foo(props) { const x = new Foo(...props.foo, null, ...[props.bar]); return x; } + +export const FIXTURE_ENTRYPOINT = { + fn: Foo, + params: [ + { + foo: [1], + bar: 2, + }, + ], +};