Interface TypeConversion

Manages conversions between different types. A conversion is a directed relationship between two types. If a source type can be converted to a target type, the source type could be assignable to the target type (depending on the conversion mode: target := source).

interface TypeConversion {
    getConversion(from: Type, to: Type): ConversionMode;
    isConvertible(from: Type, to: Type): boolean;
    isExplicitConvertible(from: Type, to: Type): boolean;
    isImplicitExplicitConvertible(from: Type, to: Type): boolean;
    isNoneConvertible(from: Type, to: Type): boolean;
    isSelfConvertible(from: Type, to: Type): boolean;
    markAsConvertible(
        from: Type | Type[],
        to: Type | Type[],
        mode: ConversionModeForSpecification,
    ): void;
}

Implemented by

Methods

  • Checks whether the given two types are convertible (EXPLICIT or IMPLICIT or SELF).

    Parameters

    • from: Type

      the from/source type

    • to: Type

      the to/target type

    Returns boolean

    true if the implicit or explicit conversion is possible or the types are equal, false otherwise

  • Checks whether the given two types are (only) explicitly convertible.

    Parameters

    • from: Type

      the from/source type

    • to: Type

      the to/target type

    Returns boolean

    true if the conversion is possible, false otherwise

  • Checks whether the given two types are implicitly (or explicitly) convertible.

    Parameters

    • from: Type

      the from/source type

    • to: Type

      the to/target type

    Returns boolean

    true if the conversion is possible, false otherwise

  • Checks whether the given two types are not convertible (and are not equals).

    Parameters

    • from: Type

      the from/source type

    • to: Type

      the to/target type

    Returns boolean

    true if the conversion is not possible, false otherwise

  • Checks whether the given two types are (implicitly or explicitly) convertible, since they are equal.

    Parameters

    • from: Type

      the from/source type

    • to: Type

      the to/target type

    Returns boolean

    true if the types are equal, false otherwise