Type Generation
FlagControl supports end-to-end type safety for your flags. You can generate TypeScript definitions from your project.
Setup
- Install the generator globally or as a dev dependency.
bash
npm install -D flagcontrol- Run the generator.
bash
npx flagcontrol --key YOUR_SDK_KEY --output ./src/flagcontrol.d.tsOr use environment variables:
bash
export FLAGCONTROL_SDK_KEY=YOUR_SDK_KEY
npx flagcontrolUsage
Once generated, the SDKs will automatically pick up the types.
typescript
// The key 'new-feature' is now type-checked!
// The return value is inferred as boolean.
const isEnabled = client.isEnabled('new-feature');
// Error: Argument of type '"invalid-flag"' is not assignable...
client.get('invalid-flag');