Skip to content

Type the unstable-internals-do-not-use entry point with Flow (#58538) - #58538

Closed
rubennorte wants to merge 3 commits into
react:mainfrom
rubennorte:export-D120124118
Closed

rubennorte wants to merge 3 commits into
react:mainfrom
rubennorte:export-D120124118

Conversation

@rubennorte

@rubennorte rubennorte commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary:

src/unstable-internals-do-not-use.js is noflow, so Flow sees nothing on the other side of react-native/unstable-internals-do-not-use and a call site importing from it gets no types at all. TypeScript consumers already have a declaration file; Flow consumers have had nothing.

This brings it in line with the sibling secondary entry point, react-private-interface, which is flow strict-local and pairs the runtime module with a .js.flow types entry point:

  • the module becomes flow strict-local, with each lazy getter annotated via import typeof and the unsafe-getters-setters flowlint disabled, exactly as react-private-interface.js and index.js do;
  • a new unstable-internals-do-not-use.js.flow declares the same ten exports for consumers.

No exports are added or removed and the runtime shape is untouched — the getters are byte-for-byte the same beyond their return annotations.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D120124118

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 15, 2026
@meta-codesync

meta-codesync Bot commented Sep 15, 2026

Copy link
Copy Markdown

@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D120124118.

@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

Summary:

The auto-fix map behind `react-native/no-deep-imports` had drifted from the exports declared in `index.js.flow`, so the rule offered fixes that do not type-check and missed fixes it could have offered.

It was missing 28 modules, among them EventEmitter, CoreEventTypes, PlatformTypes, RendererProxy, usePressability, AssetRegistry and the virtual collection components. It still listed `InteractionManager`, which has been removed from the public API and whose root getter now throws in development, and `Touchable`, which is a value-only runtime re-export absent from the published types — auto-fixing either one produces broken code. It also carried a malformed `./Libraries/Utilities/PlatformTypes` key and two type names, `NativeMethods` and `NativeMethodsMixin`, that the root module does not export. The map is now generated from `index.js.flow`, so it tracks the real surface.

Two groups of exports stay out of the map on purpose. The rule keeps reporting those deep imports; it simply does not offer a fix for them.

Renamed re-exports such as `NativeText as unstable_NativeText`, and namespace re-exports such as `export * as Systrace`, cannot be expressed by a fixer that only rewrites same-name specifiers.

Names published behind an `unstable_` or `experimental_` prefix are excluded as well. They are genuine public exports, but rewriting a deep import of `ViewNativeComponent` into `unstable_NativeView` quietly moves a call site onto an experimental API, and that is a choice the author should make rather than a lint fixer.

`InitializeCore` and `RootTagTypes` remain hand-written entries, since neither is derivable from `index.js.flow`: the first has no root export at all and is replaced wholesale by the `react-native/setup-env` entry point, and the second re-exports `RootTag`, which the root does export.

Changelog:
[General][Fixed] - Align the `react-native/no-deep-imports` auto-fix map with the package's public API

Reviewed By: javache

Differential Revision: D119678373
Summary:

`ViewToken` is already reachable from the package root as `ListViewToken`, but the two types that accompany it in every viewability API — `ViewabilityConfig` and `ViewabilityConfigCallbackPair` — are not exported at all. A call site configuring viewability on `FlatList`, `SectionList` or `VirtualizedList` therefore has to reach into `Libraries/Lists/ViewabilityHelper` for them, even though the props that consume them are public.

Both are re-exported from `Libraries/Lists/ViewabilityHelper`, which sources them from `react-native/virtualized-lists`, so this exposes the same declarations the internal path already hands out and adds no new surface beyond the names themselves.

Changelog:
[General][Added] - Export the `ViewabilityConfig` and `ViewabilityConfigCallbackPair` types from the package root

Reviewed By: javache

Differential Revision: D120124115
…8538)

Summary:

`src/unstable-internals-do-not-use.js` is `noflow`, so Flow sees nothing on the other side of `react-native/unstable-internals-do-not-use` and a call site importing from it gets no types at all. TypeScript consumers already have a declaration file; Flow consumers have had nothing.

This brings it in line with the sibling secondary entry point, `react-private-interface`, which is `flow strict-local` and pairs the runtime module with a `.js.flow` types entry point:

- the module becomes `flow strict-local`, with each lazy getter annotated via `import typeof` and the `unsafe-getters-setters` flowlint disabled, exactly as `react-private-interface.js` and `index.js` do;
- a new `unstable-internals-do-not-use.js.flow` declares the same ten exports for consumers.

No exports are added or removed and the runtime shape is untouched — the getters are byte-for-byte the same beyond their return annotations.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D120124118
@meta-codesync meta-codesync Bot changed the title Type the unstable-internals-do-not-use entry point with Flow Type the unstable-internals-do-not-use entry point with Flow (#58538) Sep 15, 2026
@meta-codesync meta-codesync Bot closed this in da03097 Sep 15, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Sep 15, 2026
@meta-codesync

meta-codesync Bot commented Sep 15, 2026

Copy link
Copy Markdown

This pull request has been merged in da03097.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant