Interface SerializerComponent<T>

Represents Serializer plugin component.

Like Converter plugins each Serializer plugin defines a predicate that instructs if an object can be serialized by it. This is done dynamically at runtime via a supports method.

Additionally, each Serializer plugin must define a predicate that instructs the group it belongs to.

interface SerializerComponent<T> {
    priority: number;
    supports(item: unknown): boolean;
    toObject(item: T, obj: Partial<ModelToObject<T>>, serializer: Serializer): Partial<ModelToObject<T>>;
}

Type Parameters

  • T extends object

Properties

Methods

Properties

priority: number

The priority this serializer should be executed with. A higher priority means the Serializer will be applied earlier.

Methods

  • Technically this should return item is T, but that doesn't play nicely with inference, so allow the looser boolean return type.

    Parameters

    • item: unknown

    Returns boolean