Decorators

@system-inc/base-foundation · 515c140 · 2 symbols

A field on a @SerializableObject class, included when instances are serialized and deserialized. The type function tells the deserializer what to construct for the property.

SerializableField(typeFunc?: TypeFunc, options?: SerializableFieldOptions): PropertyDecorator
  • typeFunc

    The type of the property.

  • options

    Field options such as `name`, `optional`, `defaultValue`, or a custom `transformer`.

@SerializableField(() => String)
accountId: string;

@SerializableField(() => Number, { optional: true })
amount?: number;

View source ↗

Marks a class as serializable, allowing instances to be converted to JSON with serialize and reconstructed with deserialize. Only properties marked @SerializableField cross the wire — internal fields never leak.

SerializableObject(): ClassDecorator
@SerializableObject()
export class ChargeInput {
    @SerializableField(() => String)
    accountId: string;

    @SerializableField(() => Number, { optional: true })
    amount?: number;
}

View source ↗