getVariantKeyValue
getVariantKeyValue<
T>(variant):CandidKeyValue<T>
Defined in: utils/candid.ts:51
Extract variant key and value from a variant type Works with types like: type User = { ‘Business’: BusinessUser } | { ‘Individual’: IndividualUser }
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 does not have exactly one key