Skip to content

Commit 86e4a09

Browse files
rickhanloniiAndyPengc12
authored andcommitted
Update RN dynamic flag types (facebook#28427)
Updates the RN flag flow types to work like www does, so we can use the `.native-fb-dynamic.js` file as the type/shim for the dynamically imported file.
1 parent 8e700a8 commit 86e4a09

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* @flow strict
88
*/
99

10-
import typeof * as ExportsType from './ReactFeatureFlags.native-fb-dynamic';
11-
import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags';
12-
1310
// In xplat, these flags are controlled by GKs. Because most GKs have some
1411
// population running in either mode, we should run our tests that way, too,
1512
//
@@ -18,7 +15,7 @@ import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags';
1815
//
1916
// TODO: __VARIANT__ isn't supported for React Native flags yet. You can set the
2017
// flag here but it won't be set to `true` in any of our test runs. Need to
21-
// update the test configuration.
18+
// add a test configuration for React Native.
2219

2320
export const alwaysThrottleDisappearingFallbacks = __VARIANT__;
2421
export const alwaysThrottleRetries = __VARIANT__;
@@ -32,6 +29,3 @@ export const enableUnifiedSyncLane = __VARIANT__;
3229
export const enableUseRefAccessWarning = __VARIANT__;
3330
export const passChildrenWhenCloningPersistedNodes = __VARIANT__;
3431
export const useModernStrictMode = __VARIANT__;
35-
36-
// Flow magic to verify the exports of this file match the original version.
37-
((((null: any): ExportsType): DynamicFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
1111
import typeof * as ExportsType from './ReactFeatureFlags.native-fb';
12+
import typeof * as DynamicExportsType from './ReactFeatureFlags.native-fb-dynamic';
1213

13-
// NOTE: There are no flags, currently. Uncomment the stuff below if we add one.
14-
// Re-export dynamic flags from the internal module. Intentionally using *
15-
// because this import is compiled to a `require` call.
16-
import * as dynamicFlags from 'ReactNativeInternalFeatureFlags';
14+
// Re-export dynamic flags from the internal module.
15+
// Intentionally using * because this import is compiled to a `require` call.
16+
import * as dynamicFlagsUntyped from 'ReactNativeInternalFeatureFlags';
17+
const dynamicFlags: DynamicExportsType = (dynamicFlagsUntyped: any);
1718

1819
// We destructure each value before re-exporting to avoid a dynamic look-up on
1920
// the exports object every time a flag is read.

scripts/flow/xplat.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,5 @@
88
*/
99

1010
declare module 'ReactNativeInternalFeatureFlags' {
11-
declare export const alwaysThrottleDisappearingFallbacks: boolean;
12-
declare export const alwaysThrottleRetries: boolean;
13-
declare export const consoleManagedByDevToolsDuringStrictMode: boolean;
14-
declare export const enableAsyncActions: boolean;
15-
declare export const enableComponentStackLocations: boolean;
16-
declare export const enableDeferRootSchedulingToMicrotask: boolean;
17-
declare export const enableInfiniteRenderLoopDetection: boolean;
18-
declare export const enableRenderableContext: boolean;
19-
declare export const enableUnifiedSyncLane: boolean;
20-
declare export const enableUseRefAccessWarning: boolean;
21-
declare export const passChildrenWhenCloningPersistedNodes: boolean;
22-
declare export const useModernStrictMode: boolean;
11+
declare module.exports: any;
2312
}

0 commit comments

Comments
 (0)