• @Else decorator acts as a fallback when no other condition is met. This decorator always executes if none of the preceding conditions passed.

    Type Parameters

    • This extends object

      The type of the class the decorator is applied to.

    • Target

      The type of the relation

    • Value

      The type of the decorated property.

    • Args extends string

    Parameters

    • Optionalthen: Primitive<Target>

      The property type to read if no other condition is met.

    • Optionalargs: RelationParameters<This, Args>

      Optional arguments passed to the nested type definition if the 'cond' pass.

    Returns DecoratorType<This, Value>

    The property decorator function.

    In the following example the data property of the Protocol class will be associated with a unsigned 8-bits integer if the type property doesn't equals to 0x01.

    class Protocol {
    @Relation(PrimitiveSymbol.u8)
    type: number

    @IfThen(_ => _.type === 0x01, PrimitiveSymbol.u16)
    @Else(PrimitiveSymbol.u8)
    data: number
    }