From cec189bd3444cd010513417631618e054bbf2981 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 27 Aug 2026 05:03:36 -0700 Subject: [PATCH] Support 'react-native/react-private-interface' in build-types (#58075) Summary: **Motivation** Minimum infra fix to enable subsequently landing https://github.com/react/react-native/pull/57940. Referencing `ReactNativeFeatureFlags` on the existing `react-native/react-private-interface` boundary is blocked by a gap in the `build-types` pipeline and a type translation error, addressed here. **Changes** - `simpleResolve.js`: Explicitly support `react-native/react-private-interface` as a special case, fixing resolution. - `ReactNativeFeatureFlagsBase.js`: Tweak the `OverridesFor` type here to fix TypeScript translation compatibility, where the unconstrained `T` type param is now narrowed. **Impact** No change to the API snapshot (the `ReactNativeFeatureFlags` import is ultimately tree-shaken!), and no effect on generated types until https://github.com/react/react-native/issues/57940 lands. Changelog: [Internal] Pull Request resolved: https://github.com/react/react-native/pull/58075 Test Plan: - `yarn build-types` - Applied https://github.com/react/react-native/issues/57940 patch on top; both stayed green, no `types_generated/**/featureflags/**` Reviewed By: GijsWeterings Differential Revision: D117513265 Pulled By: cortinico fbshipit-source-id: 348e8de3d622081fe0062ef939ce14c21af587a8 --- .../featureflags/ReactNativeFeatureFlagsBase.js | 7 ++++--- .../js-api/build-types/resolution/simpleResolve.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js index c27f2f2e022..2bdedc1acc3 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js @@ -26,9 +26,10 @@ export type Getter = () => T; // This defines the types for the overrides object, whose methods can return // null or undefined to fallback to the default value. -export type OverridesFor = Partial<{ - [key in keyof T]: Getter>, -}>; +export type OverridesFor unknown}> = + Partial<{ + [key in keyof T]: Getter>, + }>; function createGetter( configName: string, diff --git a/scripts/js-api/build-types/resolution/simpleResolve.js b/scripts/js-api/build-types/resolution/simpleResolve.js index 8bdb14383ca..c78fe4a65ca 100644 --- a/scripts/js-api/build-types/resolution/simpleResolve.js +++ b/scripts/js-api/build-types/resolution/simpleResolve.js @@ -8,7 +8,10 @@ * @format */ -const {PACKAGES_DIR} = require('../../../shared/consts'); +const { + PACKAGES_DIR, + REACT_NATIVE_PACKAGE_DIR, +} = require('../../../shared/consts'); const {getPackages} = require('../../../shared/monorepoUtils'); const {existsSync} = require('node:fs'); const path = require('node:path'); @@ -38,6 +41,14 @@ async function simpleResolve( }); } + // Resolve the 'react-native/react-private-interface' subpath export + if (importPath === 'react-native/react-private-interface') { + return path.join( + REACT_NATIVE_PACKAGE_DIR, + 'src/react-private-interface.js', + ); + } + // Resolve exact '@react-native/' import if (importPath in cachedProjectInfo) { const packageJson = cachedProjectInfo[importPath].packageJson;