The Flagship binding uses the following TypeScript types. Generate binding types with wrangler types or use the @cloudflare/workers-types package.
The binding type. Each Flagship binding in your Wrangler configuration is typed as Flagship on the Env interface.
interface Env {
FLAGS: Flagship;
}Refer to the methods reference for the full list of evaluation methods available on the binding.
A record of attributes passed to targeting rules. Values can recursively contain arrays and objects.
type FlagshipEvaluationContextValue =
| string
| number
| boolean
| null
| FlagshipEvaluationContextValue[]
| { [key: string]: FlagshipEvaluationContextValue };
type FlagshipEvaluationContext = Record<string, FlagshipEvaluationContextValue>;Numbers must be finite. The binding rejects NaN, Infinity, unsupported objects, and cyclic values.
The runtime also accepts valid JavaScript Date values. The binding normalizes each date to an ISO 8601 string. Invalid dates produce an INVALID_CONTEXT error.
Serialize Date values to ISO 8601 strings before passing them to the binding in TypeScript. The context type describes JSON values and does not include Date.
Returned by the *Details methods. Contains the evaluated value and metadata about how Flagship resolved the flag.
interface FlagshipEvaluationDetails<T> {
flagKey: string;
value: T;
variant?: string;
reason?: string;
errorCode?: string;
errorMessage?: string;
}| Property | Type | Description |
|---|---|---|
flagKey |
string |
The key of the evaluated flag. |
value |
T |
The resolved flag value. |
variant |
string |
The name of the matched variant, if any. |
reason |
string |
Why the flag resolved to this value (for example, "TARGETING_MATCH" or "DEFAULT"). |
errorCode |
string |
An error code if evaluation failed (for example, "TYPE_MISMATCH" or "GENERAL"). |
errorMessage |
string |
A description of the evaluation error, if any. |
Refer to evaluation reasons and error codes for the full list of possible values.