From a9f8aed08676f4bda2dbc6fafdb2a15692548f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 28 Oct 2024 04:57:57 -0700 Subject: [PATCH] Small improvement in types for feature flags definitions in JS Summary: Changelog: [internal] Small refactor of the types for feature flags in JS to make objects read-only. Differential Revision: D65058612 --- .../scripts/featureflags/types.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/react-native/scripts/featureflags/types.js b/packages/react-native/scripts/featureflags/types.js index 1e328087159714..9316c9487f4e72 100644 --- a/packages/react-native/scripts/featureflags/types.js +++ b/packages/react-native/scripts/featureflags/types.js @@ -10,30 +10,30 @@ export type FeatureFlagValue = boolean | number | string; -export type FeatureFlagDefinitions = { +export type FeatureFlagDefinitions = $ReadOnly<{ common: CommonFeatureFlagList, jsOnly: JsOnlyFeatureFlagList, -}; +}>; -type CommonFeatureFlagList = { - [flagName: string]: { +export type CommonFeatureFlagList = $ReadOnly<{ + [flagName: string]: $ReadOnly<{ defaultValue: FeatureFlagValue, metadata: FeatureFlagMetadata, // Indicates if this API should only be defined in JavaScript, only to // preserve backwards compatibility with existing native code temporarily. skipNativeAPI?: true, - }, -}; + }>, +}>; -type JsOnlyFeatureFlagList = { - [flagName: string]: { +export type JsOnlyFeatureFlagList = $ReadOnly<{ + [flagName: string]: $ReadOnly<{ defaultValue: FeatureFlagValue, metadata: FeatureFlagMetadata, - }, -}; + }>, +}>; -type FeatureFlagMetadata = - | { +export type FeatureFlagMetadata = + | $ReadOnly<{ purpose: 'experimentation', /** * Aproximate date when the flag was added. @@ -41,25 +41,25 @@ type FeatureFlagMetadata = */ dateAdded: string, description: string, - } - | { + }> + | $ReadOnly<{ purpose: 'operational' | 'release', description: string, - }; + }>; -export type GeneratorConfig = { +export type GeneratorConfig = $ReadOnly<{ featureFlagDefinitions: FeatureFlagDefinitions, jsPath: string, commonCxxPath: string, commonNativeModuleCxxPath: string, androidPath: string, androidJniPath: string, -}; +}>; -export type GeneratorOptions = { +export type GeneratorOptions = $ReadOnly<{ verifyUnchanged: boolean, -}; +}>; -export type GeneratorResult = { +export type GeneratorResult = $ReadOnly<{ [path: string]: string /* content */, -}; +}>;