#
FeatureFlags
The FeatureFlags interface defines the shape and types of the feature flags keys and values that modules evaluates through the FireflyRuntime instance and other utility hooks and functions.
Consumer applications are expected to augment this interface to declare the feature flags they intend to evaluate, providing a fully type-safe experience when working with feature flags.
#
Augment the interface
First, create a types folder in the project:
project
├── src
├────── register.tsx
├────── Page.tsx
├────── index.tsx
├────── App.tsx
├── types
├────── feature-flags.d.ts
Then create an feature-flags.d.ts file:
project/types/feature-flags.d.ts
import "@squide/firefly";
declare module "@squide/firefly" {
interface FeatureFlags {
// In the example above, the module only intends to evaliate the `show-characters` feature flag.
"show-characters": boolean;
}
}
Finally, update the project tsconfig.json to include the types folder:
project/tsconfig.json
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
"types": [
"./types/feature-flags.d.ts"
]
},
"exclude": ["dist", "node_modules"]
}
Any project that uses these feature flags must also reference the project's feature-flags.d.ts file:
project/tsconfig.json
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
"types": [
"../another-project/types/feature-flags.d.ts"
]
},
"exclude": ["dist", "node_modules"]
}