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
This commit is contained in:
Alex Hunt
2026-08-27 05:03:36 -07:00
committed by meta-codesync[bot]
parent 593ae0258d
commit cec189bd34
2 changed files with 16 additions and 4 deletions
@@ -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/<package>' import
if (importPath in cachedProjectInfo) {
const packageJson = cachedProjectInfo[importPath].packageJson;