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” }
Type Parameters
Section titled “Type Parameters”T extends Record<string, any>
The variant type
Parameters
Section titled “Parameters”variant
Section titled “variant”T
Returns
Section titled “Returns”A tuple containing the key and value of the variant
Throws
Section titled “Throws”Error if the variant object is malformed