Skip to content

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.


When using TypeScript add an ambient type definition using Declaration Merging typing your features, for example:

This can be done manually e.g.

import '@featureboard/js-sdk'
declare module '@featureboard/js-sdk' {
interface Features {
'my-boolean-feature-key': boolean
'my-option-feature-key': string
'my-number-feature-key': number
'my-string-feature-key': string

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:

declare module '@featureboard/js-sdk' {
interface Features extends Record<string, string | number | boolean> {}

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