Skip to content

Types

The Flagship binding uses the following TypeScript types. These are available from the @cloudflare/workers-types package after running npx wrangler types.

Flagship

The binding type. Each Flagship binding in your Wrangler configuration is typed as Flagship on the Env interface.

TypeScript
interface Env {
FLAGS: Flagship;
}

Refer to the methods reference for the full list of evaluation methods available on the binding.

FlagshipEvaluationContext

A record of attribute names to values passed for targeting rules. Use this to provide user attributes such as user ID, country, or plan type.

TypeScript
type FlagshipEvaluationContext = Record<string, string | number | boolean>;

FlagshipEvaluationDetails

Returned by the *Details methods. Contains the evaluated value and metadata about how Flagship resolved the flag.

TypeScript
interface FlagshipEvaluationDetails<T> {
flagKey: string;
value: T;
variant?: string;
reason?: string;
errorCode?: string;
errorMessage?: string;
}
PropertyTypeDescription
flagKeystringThe key of the evaluated flag.
valueTThe resolved flag value.
variantstringThe name of the matched variation, if any.
reasonstringWhy the flag resolved to this value (for example, "TARGETING_MATCH" or "DEFAULT").
errorCodestringAn error code if evaluation failed (for example, "TYPE_MISMATCH" or "GENERAL").
errorMessagestringA human-readable description of the error.

Refer to evaluation reasons and error codes for the full list of possible values.