Skip to content

Commit

Permalink
Small improvement in types for feature flags definitions in JS (faceb…
Browse files Browse the repository at this point in the history
…ook#47239)

Summary:

Changelog: [internal]

Small refactor of the types for feature flags in JS to make objects read-only.

Reviewed By: mdvacca

Differential Revision: D65058612
  • Loading branch information
rubennorte authored and facebook-github-bot committed Oct 29, 2024
1 parent eaa2098 commit d6015e5
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions packages/react-native/scripts/featureflags/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,56 @@

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.
* Used to help prioritize feature flags that need to be cleaned up.
*/
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 */,
};
}>;

0 comments on commit d6015e5

Please sign in to comment.