Overview
The CLI generates TypeScript types or Go accessors from the local flag config. TypeScript output defaults tosrc/generated/flags.ts. Pass its FlagDefinitions type to the SDK and flag keys, variant names, and value types are checked at compile time. A misspelled key fails the build instead of silently serving a default.
Generated output
When it is written
Types always come from the local flag config, never from the server. To write somewhere else, set
typesOut in .shipd/config.json:
Commit it
Commitsrc/generated/flags.ts alongside shipd.config.ts. Your app then type-checks on a fresh clone and in CI without running the CLI first, and pull requests show type changes next to flag changes.
- Never edit it by hand. The next push, pull, or
shipd types genoverwrites it. - If it drifts from
shipd.config.ts, runshipd types genand commit the result. - To catch drift in CI, run
shipd types genand fail ongit diff --exit-code src/generated/flags.ts.
Use generated output with the SDK
PassFlagDefinitions as the TypeScript client type argument, or import your module’s generated Go flags package.
src/flags.ts (React)
Go output
typesLanguage: "go" and typesPackage: "flags" in project settings to generate Go after push and pull too. Go output defaults to internal/flags/flags_gen.go.
The Go output above uses the four flags from the Go tutorial. The generator creates one accessor per flag, its key constant, a Defaults() function, and named string types and constants for variants.
Misspelled accessor names and incompatible return types fail compilation. Go variant types are named strings, so Go still permits explicit conversions from arbitrary strings; they are not closed unions. JSON stays any because the served payload can change shape.
Flag keys become exported Go names (new-checkout → NewCheckout). Identifier collisions such as new-checkout and new_checkout, including collisions with generated variant constants, fail generation with a validation error. Rename the conflicting flag or variant.
Commit internal/flags/flags_gen.go alongside the config. Check drift with:
What a mistake looks like
Output
shipd.isEnabled("search-variant")) and comparing against a variant that does not exist (shipd.getVariant("search-variant") === "v3").