Flipt Typed
Generate static types from Flipt features. Validate your code against your feature flags.
Overview
Flipt Typed is a CLI tool that generates static types from Flipt features.yml files. It allows you to use Flipt feature flags in your code with type safety for flag keys, variants, and contexts.
It is currently experimental and under active development.
Language support is limited to TypeScript at the moment, however we plan to add support for other typed languages in the future.
Want support for your favorite language? Let us know!
Why
Why would you want to use Flipt Typed? Here are a few reasons:
- Get IDE autocompletion and enable a safer and more streamlined development experience when using Flipt feature flags
- Avoid typos and other errors when integrating Flipt flag evaluation into your codebase
- Ensure that your code is always in sync with your Flipt features configuration
- Enable easier refactoring/cleanup of unused flags with Go To Definition and Find References in your IDE
Usage
-
Create Flags, Variants, Segments, etc in Flipt. See our Getting Started guide for more information.
-
Export your Flipt features to a
features.yml
file viaflipt export
. See our export documentation for more information. -
Run
npx @flipt-io/typed
to generate static types from yourfeatures.yml
file.Either copy and paste the output or pipe it to a file:
npx @flipt-io/typed --lang ts --input /path/to/features.yml npx @flipt-io/typed --lang ts --input /path/to/features.yml > /types/flipt.ts
-
Use the generated types in your code:
import { Flag } from "./types/flipt"; let flag: Flag = { key: "new-feature", value: true };
Contributing
We welcome contributions to Flipt Typed! Please see our contributing guide for more information.
Found a bug or have a feature request? Open an issue.
License
Flipt Typed is licensed under the MIT License.
Acknowledgements
Thanks to @graup for the initial idea and prototype implementation of Flipt Typed!