diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-gating-with-react-memo.flow.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-gating-with-react-memo.flow.expect.md new file mode 100644 index 0000000000..670125a747 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-gating-with-react-memo.flow.expect.md @@ -0,0 +1,32 @@ + +## Input + +```javascript +// @flow @gating +import { memo } from "react"; + +// TODO: this appears as a hoisted reference to Component, but it's a type not runtime reference! +type Props = React.ElementConfig; + +component Component(value: string) { + return
{value}
; +} + +export default memo(Component); + +``` + + +## Error + +``` + 5 | type Props = React.ElementConfig; + 6 | +> 7 | component Component(value: string) { + | ^^^^^^^^^ Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Component to not rely on hoisting to fix this issue (7:7) + 8 | return
{value}
; + 9 | } + 10 | +``` + + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-gating-with-react-memo.flow.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-gating-with-react-memo.flow.js new file mode 100644 index 0000000000..6130717ec1 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-gating-with-react-memo.flow.js @@ -0,0 +1,11 @@ +// @flow @gating +import { memo } from "react"; + +// TODO: this appears as a hoisted reference to Component, but it's a type not runtime reference! +type Props = React.ElementConfig; + +component Component(value: string) { + return
{value}
; +} + +export default memo(Component);