SDK
TypeScript Types
All exported TypeScript types from the Switchflag SDK.
Core types
These types are re-exported from @switchflag/shared and available from both import paths.
EvaluationContext
The context object passed to getFlag and evaluateAtEdge. Used by the evaluation engine to match targeting rules.
interface EvaluationContext {
readonly userId?: string
readonly email?: string
readonly country?: string
readonly [key: string]: unknown
}Built-in properties are optional. You can add any custom attributes for use in targeting rules.
EvaluationResult
The result of evaluating a feature flag.
interface EvaluationResult<T = unknown> {
readonly value: T
readonly reason: EvaluationReason
readonly ruleId?: string
}EvaluationReason
type EvaluationReason = 'default' | 'rule_match' | 'disabled' | 'not_found'Standard SDK types
Exported from @switchflag/sdk.
ClientConfig
interface ClientConfig {
readonly apiKey: string
readonly baseUrl?: string | undefined
}SwitchflagClient
interface SwitchflagClient {
readonly getFlag: <T>(
key: string,
context: EvaluationContext,
) => Promise<EvaluationResult<T>>
}Edge SDK types
Exported from @switchflag/sdk/edge.
EdgeConfig
interface EdgeConfig {
readonly apiKey: string
readonly baseUrl?: string
}Flag types
These types are used internally and in the API response. They're defined in @switchflag/shared but not exported from the SDK.
FlagType
type FlagType = 'boolean' | 'string' | 'number' | 'json'RuleOperator
The 10 operators available for targeting rules:
type RuleOperator =
| 'equals'
| 'notEquals'
| 'contains'
| 'startsWith'
| 'endsWith'
| 'in'
| 'notIn'
| 'greaterThan'
| 'lessThan'
| 'percent'OrganizationRole
type OrganizationRole = 'owner' | 'admin' | 'member'