Skip to content

getVariantKeyValue

getVariantKeyValue<T>(variant): CandidKeyValue<T>

Defined in: utils/candid.ts:95

Extract variant key and value from a variant type Works with types like: type User = { ‘Business’: BusinessUser } | { ‘Individual’: IndividualUser } Also supports display variants shaped like: { _type: “Business”, Business: value } or { _type: “Individual” }

T extends Record<string, any>

The variant type

T

CandidKeyValue<T>

A tuple containing the key and value of the variant

Error if the variant object is malformed