From 48de2f6dbc3223d9a78226280e89b646f4b38f5d Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Thu, 22 Feb 2024 21:10:47 -0500 Subject: [PATCH] Update RN dynamic flag types --- .../shared/forks/ReactFeatureFlags.native-fb-dynamic.js | 8 +------- packages/shared/forks/ReactFeatureFlags.native-fb.js | 9 +++++---- scripts/flow/xplat.js | 7 +------ 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js b/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js index ccaa927e65c57..9f4b1d5cf5e62 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js @@ -7,9 +7,6 @@ * @flow strict */ -import typeof * as ExportsType from './ReactFeatureFlags.native-fb-dynamic'; -import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags'; - // In xplat, these flags are controlled by GKs. Because most GKs have some // population running in either mode, we should run our tests that way, too, // @@ -18,7 +15,7 @@ import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags'; // // TODO: __VARIANT__ isn't supported for React Native flags yet. You can set the // flag here but it won't be set to `true` in any of our test runs. Need to -// update the test configuration. +// add a test configuration for React Native. export const alwaysThrottleRetries = __VARIANT__; export const enableComponentStackLocations = __VARIANT__; @@ -26,6 +23,3 @@ export const enableDeferRootSchedulingToMicrotask = __VARIANT__; export const enableUseRefAccessWarning = __VARIANT__; export const passChildrenWhenCloningPersistedNodes = __VARIANT__; export const useMicrotasksForSchedulingInFabric = __VARIANT__; - -// Flow magic to verify the exports of this file match the original version. -((((null: any): ExportsType): DynamicFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 42d7a0bbcf992..aefbdfaa3d957 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -9,11 +9,12 @@ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.native-fb'; +import typeof * as DynamicExportsType from './ReactFeatureFlags.native-fb-dynamic'; -// NOTE: There are no flags, currently. Uncomment the stuff below if we add one. -// Re-export dynamic flags from the internal module. Intentionally using * -// because this import is compiled to a `require` call. -import * as dynamicFlags from 'ReactNativeInternalFeatureFlags'; +// Re-export dynamic flags from the internal module. +// Intentionally using * because this import is compiled to a `require` call. +import * as dynamicFlagsUntyped from 'ReactNativeInternalFeatureFlags'; +const dynamicFlags: DynamicExportsType = (dynamicFlagsUntyped: any); // We destructure each value before re-exporting to avoid a dynamic look-up on // the exports object every time a flag is read. diff --git a/scripts/flow/xplat.js b/scripts/flow/xplat.js index 33d061083985c..3b8afbd894ff3 100644 --- a/scripts/flow/xplat.js +++ b/scripts/flow/xplat.js @@ -8,10 +8,5 @@ */ declare module 'ReactNativeInternalFeatureFlags' { - declare export var alwaysThrottleRetries: boolean; - declare export var enableComponentStackLocations: boolean; - declare export var enableDeferRootSchedulingToMicrotask: boolean; - declare export var enableUseRefAccessWarning: boolean; - declare export var passChildrenWhenCloningPersistedNodes: boolean; - declare export var useMicrotasksForSchedulingInFabric: boolean; + declare module.exports: any; }