TypeScript Support
The FeatureBoard SDK is written in TypeScript and includes type definitions but it can be used in any JavaScript project.
This guide will show you how to improve the type safety of your FeatureBoard integration.
Setup
When using TypeScript add an ambient type definition using Declaration Merging typing your features, for example:
This can be done manually e.g.
Or automatically via the cli tool
By running npx @featureboard/cli login
, then npx @featureboard/cli code-gen --template typescript --output ./
to generate a features.ts file in the output path or update an existing one.
OR if you do not want to specify all your features the features you can just add:
NOTE: It is important you import the @featureboard/js-sdk
module before you declare the module, otherwise the type definitions will not be merged and you will not be able to import any of the other functions from @featureboard/js-sdk