@samitouri / QOS-React / commits / fa0efa1ae3

Update RN dynamic flag types (#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.

Ricky committed Mar 22, 2024 at 12:23 UTC fa0efa1ae3b83e573e21dfd6d0620039fa7fedd3
3 files changed +7 -23
packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js
+1 -7
@@ -7,9 +7,6 @@
7 * @flow strict
8 */
9
10 -import typeof * as ExportsType from './ReactFeatureFlags.native-fb-dynamic';
11 -import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags';
12 -
10 // In xplat, these flags are controlled by GKs. Because most GKs have some
11 // population running in either mode, we should run our tests that way, too,
12 //
@@ -18,7 +15,7 @@ import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags';
15 //
16 // TODO: __VARIANT__ isn't supported for React Native flags yet. You can set the
17 // 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.
19
20 export const alwaysThrottleDisappearingFallbacks = __VARIANT__;
21 export const alwaysThrottleRetries = __VARIANT__;
@@ -32,6 +29,3 @@ export const enableUnifiedSyncLane = __VARIANT__;
29 export const enableUseRefAccessWarning = __VARIANT__;
30 export const passChildrenWhenCloningPersistedNodes = __VARIANT__;
31 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
+5 -4
@@ -9,11 +9,12 @@
9
10 import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
11 import typeof * as ExportsType from './ReactFeatureFlags.native-fb';
12 +import typeof * as DynamicExportsType from './ReactFeatureFlags.native-fb-dynamic';
13
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);
18
19 // We destructure each value before re-exporting to avoid a dynamic look-up on
20 // the exports object every time a flag is read.
scripts/flow/xplat.js
+1 -12
@@ -8,16 +8,5 @@
8 */
9
10 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;
12 }