Skip to content

CLI tool to generate TypeScript types from a LaunchDarkly project.

License

Notifications You must be signed in to change notification settings

jonlambert/launchdarkly-typegen

Repository files navigation

LaunchDarkly TypeScript Generator

Type-safe flag evaluations for LaunchDarkly.

Note: This is a third-party tool with no affiliation to LaunchDarkly.

Introduction

This CLI tool will fetch flags from a LaunchDarkly project and render them to TypeScript definitions.

The output can then be imported across your application to give build-time checks to your flag evaluations.

Example

export interface AppFlagSet {
  'feature-one': boolean;
  'feature-two': boolean;
}

export type AppFlag = keyof AppFlagSet;

export type FlagEnvironment = 'staging' | 'production';

Installation

npx launchdarkly-typegen@latest

or

# Lock a version
npm install -D launchdarkly-typegen

Usage

launchdarkly-typegen

Usage:
  $ npx launchdarkly-typegen@latest <command> [options]

Options:
  --output [file]               Path to generated file (default: output to stdout)
  --project [project]           LaunchDarkly project key (default: default)
  --flag-interface-name [name]  Name of the generated flag interface (default: AppFlagSet)
  --env-type-name [name]        Name of the generated environment union type (default: FlagEnvironment)
  --api-key [key]               LaunchDarkly API key (if not set, will attempt to use LAUNCHDARKLY_API_KEY from the environment)
  -h, --help                    Display this message

Features

  • Fetch flag keys and their types
  • Fetch environment keys
  • Output to stdout or write to file
  • Support non-boolean flag types

About

CLI tool to generate TypeScript types from a LaunchDarkly project.

Resources

License

Stars

Watchers

Forks

Packages

No packages published