Skip to content

Commit cec189b

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Support 'react-native/react-private-interface' in build-types (#58075)
Summary: **Motivation** Minimum infra fix to enable subsequently landing #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 #57940 lands. Changelog: [Internal] Pull Request resolved: #58075 Test Plan: - `yarn build-types` - Applied #57940 patch on top; both stayed green, no `types_generated/**/featureflags/**` Reviewed By: GijsWeterings Differential Revision: D117513265 Pulled By: cortinico fbshipit-source-id: 348e8de3d622081fe0062ef939ce14c21af587a8
1 parent 593ae02 commit cec189b

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ export type Getter<T> = () => T;
2626

2727
// This defines the types for the overrides object, whose methods can return
2828
// null or undefined to fallback to the default value.
29-
export type OverridesFor<T> = Partial<{
30-
[key in keyof T]: Getter<?ReturnType<T[key]>>,
31-
}>;
29+
export type OverridesFor<T extends {readonly [string]: () => unknown}> =
30+
Partial<{
31+
[key in keyof T]: Getter<?ReturnType<T[key]>>,
32+
}>;
3233

3334
function createGetter<T extends boolean | number | string>(
3435
configName: string,

‎scripts/js-api/build-types/resolution/simpleResolve.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
* @format
99
*/
1010

11-
const {PACKAGES_DIR} = require('../../../shared/consts');
11+
const {
12+
PACKAGES_DIR,
13+
REACT_NATIVE_PACKAGE_DIR,
14+
} = require('../../../shared/consts');
1215
const {getPackages} = require('../../../shared/monorepoUtils');
1316
const {existsSync} = require('node:fs');
1417
const path = require('node:path');
@@ -38,6 +41,14 @@ async function simpleResolve(
3841
});
3942
}
4043

44+
// Resolve the 'react-native/react-private-interface' subpath export
45+
if (importPath === 'react-native/react-private-interface') {
46+
return path.join(
47+
REACT_NATIVE_PACKAGE_DIR,
48+
'src/react-private-interface.js',
49+
);
50+
}
51+
4152
// Resolve exact '@react-native/<package>' import
4253
if (importPath in cachedProjectInfo) {
4354
const packageJson = cachedProjectInfo[importPath].packageJson;

0 commit comments

Comments
 (0)