Skip to content

[noop] Typecheck react-noop-renderer against host config and renderer API#644

Closed
everettbu wants to merge 3 commits into
mainfrom
sebbie/03-02-_noop_typecheck_react-noop-renderer_against_host_config_and_renderer_api
Closed

[noop] Typecheck react-noop-renderer against host config and renderer API#644
everettbu wants to merge 3 commits into
mainfrom
sebbie/03-02-_noop_typecheck_react-noop-renderer_against_host_config_and_renderer_api

Conversation

@everettbu

@everettbu everettbu commented Mar 2, 2026

Copy link
Copy Markdown

Mirror of facebook/react#35944
Original author: eps1lon


The react-noop-renderer was not actually typechecked against the host config and renderer API. This missed a bunch of bugs due to wrong argument or missing host config.

Not implementing certain host configs should be done explicitly (e.g. throwing) instead of just omission. This makes it clearer why certain tests can't be written against the noop renderer.

This PR only sets up typechecking by adding a new inlined host config for the react-noop-renderer package. No runtime behavior should be changed. In follow-ups, I'll adjust the runtime to fix the type issues.

With types, setting up test infra for new features is easier (e.g. writing ViewTransition tests against the noop renderer).

Test plan

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 2, 2026
@everettbu
everettbu force-pushed the sebbie/03-02-_noop_typecheck_react-noop-renderer_against_host_config_and_renderer_api branch from 6af11f2 to 807c8de Compare March 2, 2026 19:25
@everettbu
everettbu marked this pull request as ready for review March 2, 2026 20:22
@greptile-apps

greptile-apps Bot commented Mar 2, 2026

Copy link
Copy Markdown

Greptile Summary

This PR sets up proper Flow typechecking for the react-noop-renderer package by creating dedicated noop host config shims for the reconciler, Fizz server, Flight server, Flight client, and stream config. Previously, react-noop-renderer was entirely excluded from Flow typechecking via the flowconfig ignore list.

  • Adds a new noop entry in inlinedHostConfigs.js with proper entrypoints, paths, and isFlowTyped: true
  • Creates ReactFiberConfigNoop.js to share concrete type definitions (Instance, TextInstance, HostContext, PublicInstance, TransitionStatus) between the noop renderer and its host config shim
  • Creates noop fork files (ReactFiberConfig.noop.js, ReactFizzConfig.noop.js, ReactFlightServerConfig.noop.js, ReactFlightClientConfig.noop.js, ReactServerStreamConfig.noop.js) mirroring the existing custom fork pattern
  • Adds $FlowFixMe suppressions throughout noop renderer files for known type mismatches, to be addressed in follow-up PRs
  • Adds typed factory function declarations to react-reconciler/index.js, react-server/index.js, react-server/flight.js, and react-client/flight.js
  • Consolidates the persistent noop renderer Jest mock into setupHostConfigs.js (removing duplicates from setupTests.persistent.js and setupTests.xplat.js)

Confidence Score: 4/5

  • This PR is safe to merge — it only adds typechecking infrastructure and Flow suppressions with no runtime behavior changes.
  • The PR is a well-structured typechecking setup that mirrors established patterns (custom fork configs). All new noop fork files match their custom counterparts exactly. The $FlowFixMe suppressions are intentional and documented for follow-up fixes. The Jest mock consolidation maintains correct execution order. The only concern is the pre-existing boundary.status vs boundary.state bug in ReactNoopServer.js which is suppressed rather than fixed, but this is explicitly called out for follow-up work.
  • packages/react-noop-renderer/src/ReactNoopServer.js has a pre-existing property name bug (boundary.status should be boundary.state) that is now suppressed with $FlowFixMe rather than fixed.

Important Files Changed

Filename Overview
packages/react-noop-renderer/src/createReactNoop.js Major refactoring: extracts type definitions to shared module, adds Flow type annotations throughout, and introduces $FlowFixMe suppressions for known type mismatches. Function signature for createReactNoop now typed with HostConfig and ReconcilerAPI.
packages/react-reconciler/src/forks/ReactFiberConfig.noop.js New file: noop host config shim for react-reconciler, mirroring the custom.js pattern but re-exporting concrete types from ReactFiberConfigNoop.js. Exports match the custom version exactly.
packages/react-noop-renderer/src/ReactFiberConfigNoop.js New file: shared type definitions (HostContext, TextInstance, Instance, PublicInstance, TransitionStatus) extracted from createReactNoop.js so they can be imported by both the noop renderer and the noop host config shim.
packages/react-noop-renderer/src/ReactNoopServer.js Type fixes for Fizz SSR noop renderer: Segment.children changed to array, Placeholder.parent union expanded, $FlowFixMe suppressions added. Contains pre-existing boundary.status bug (line 320) now suppressed with $FlowFixMe.
packages/react-noop-renderer/src/ReactNoopFlightClient.js Adds Flow type suppressions for known type mismatches in the noop flight client, including an extra 0 argument to processBinaryChunk and incompatible call parameters to createResponse.
packages/react-noop-renderer/src/ReactNoopFlightServer.js Updates Destination type to accept strings alongside Uint8Array, adds $FlowFixMe suppressions for type mismatches in createRequest and startFlowing calls.
scripts/shared/inlinedHostConfigs.js Adds new 'noop' entry with proper entryPoints and paths, enabling Flow typechecking for the noop renderer. Correctly sets isFlowTyped: true and isServerSupported: true.
scripts/flow/config/flowconfig Removes the Flow ignore for react-noop-renderer package, enabling typechecking now that proper host config shims exist.
scripts/jest/setupHostConfigs.js Moves the persistent noop renderer mock from setup test files into setupHostConfigs.js, gated behind global.__PERSISTENT__. Mock order is correct since setup files run before this file loads.

Last reviewed commit: e7193ce

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +319 to 320
// $FlowFixMe[prop-missing]
boundary.status = 'client-render';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: boundary.status should be boundary.state

The SuspenseInstance type (line 37-40) defines a state property, not status. The analogous method writeCompletedBoundaryInstruction (line 310) correctly uses boundary.state = 'complete', but this line incorrectly uses boundary.status. The $FlowFixMe[prop-missing] suppression hides a real bug rather than just a harmless type mismatch.

Since the goal of this PR is to set up typechecking for the noop renderer, this is an opportunity to fix the property name rather than suppress it:

Suggested change
// $FlowFixMe[prop-missing]
boundary.status = 'client-render';
// $FlowFixMe[prop-missing]
boundary.state = 'client-render';
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-noop-renderer/src/ReactNoopServer.js
Line: 319-320

Comment:
**Bug: `boundary.status` should be `boundary.state`**

The `SuspenseInstance` type (line 37-40) defines a `state` property, not `status`. The analogous method `writeCompletedBoundaryInstruction` (line 310) correctly uses `boundary.state = 'complete'`, but this line incorrectly uses `boundary.status`. The `$FlowFixMe[prop-missing]` suppression hides a real bug rather than just a harmless type mismatch.

Since the goal of this PR is to set up typechecking for the noop renderer, this is an opportunity to fix the property name rather than suppress it:

```suggestion
    // $FlowFixMe[prop-missing]
    boundary.state = 'client-render';
```

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

...like for the other renderers
@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Mar 4, 2026
@everettbu
everettbu deleted the sebbie/03-02-_noop_typecheck_react-noop-renderer_against_host_config_and_renderer_api branch March 4, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants