Interface ModelProp<TPropValue, TPropCreationValue, TTransformedValue, TTransformedCreationValue, TIsRequired, TIsId, THasSetter, TFromSnapshotOverride, TToSnapshotOverride>

A model property.

interface ModelProp<
    TPropValue,
    TPropCreationValue,
    TTransformedValue,
    TTransformedCreationValue,
    TIsRequired,
    TIsId extends boolean = false,
    THasSetter = never,
    TFromSnapshotOverride = never,
    TToSnapshotOverride = never,
> {
    _defaultFn: () => TPropValue | typeof noDefaultValue;
    _defaultValue: TPropValue | typeof noDefaultValue;
    _fromSnapshotProcessor?: (sn: unknown) => unknown;
    _isId: boolean;
    _setter: boolean | "assign";
    _toSnapshotProcessor?: (sn: unknown) => unknown;
    _transform:
        | undefined
        | {
            transform: (
                original: unknown,
                model: object,
                propName: PropertyKey,
                setOriginalValue: (newOriginalValue: unknown) => void,
            ) => unknown;
            untransform: (
                transformed: unknown,
                model: object,
                propName: PropertyKey,
            ) => unknown;
        };
    _typeChecker: undefined
    | TypeChecker
    | LateTypeChecker;
    $creationValueType: TPropCreationValue;
    $fromSnapshotOverride: TFromSnapshotOverride;
    $hasSetter: THasSetter;
    $isId: TIsId;
    $isRequired: TIsRequired;
    $toSnapshotOverride: TToSnapshotOverride;
    $transformedCreationValueType: TTransformedCreationValue;
    $transformedValueType: TTransformedValue;
    $valueType: TPropValue;
    withSetter(): ModelProp<
        TPropValue,
        TPropCreationValue,
        TTransformedValue,
        TTransformedCreationValue,
        TIsRequired,
        TIsId,
        string,
        TFromSnapshotOverride,
        TToSnapshotOverride,
    >;
    withSetter(
        mode: "assign",
    ): ModelProp<
        TPropValue,
        TPropCreationValue,
        TTransformedValue,
        TTransformedCreationValue,
        TIsRequired,
        TIsId,
        string,
        TFromSnapshotOverride,
        TToSnapshotOverride,
    >;
    withSnapshotProcessor<
        FS = TFromSnapshotOverride,
        TS = TToSnapshotOverride,
        This extends
            AnyModelProp = ModelProp<
            TPropValue,
            TPropCreationValue,
            TTransformedValue,
            TTransformedCreationValue,
            TIsRequired,
            TIsId,
            THasSetter,
            TFromSnapshotOverride,
            TToSnapshotOverride,
        >,
    >(
        processor: {
            fromSnapshot?: (
                sn: FS,
            ) => IsNeverType<
                This["$fromSnapshotOverride"],
                SnapshotInOf<This["$creationValueType"]>,
                This["$fromSnapshotOverride"],
            >;
            toSnapshot?: (
                sn: IsNeverType<
                    This["$toSnapshotOverride"],
                    SnapshotOutOf<This["$valueType"]>,
                    This["$toSnapshotOverride"],
                >,
            ) => TS;
        },
    ): ModelProp<
        TPropValue,
        TPropCreationValue,
        TTransformedValue,
        TTransformedCreationValue,
        TIsRequired,
        TIsId,
        THasSetter,
        FS,
        TS,
    >;
    withTransform<TTV>(
        transform: ModelPropTransform<NonNullable<TPropValue>, TTV>,
    ): ModelProp<
        TPropValue,
        TPropCreationValue,
        TTV
        | Extract<TPropValue, undefined | null>,
        TTV | Extract<TPropCreationValue, undefined | null>,
        TIsRequired,
        TIsId,
        THasSetter,
        TFromSnapshotOverride,
        TToSnapshotOverride,
    >;
}

Type Parameters

  • TPropValue
  • TPropCreationValue
  • TTransformedValue
  • TTransformedCreationValue
  • TIsRequired
  • TIsId extends boolean = false
  • THasSetter = never
  • TFromSnapshotOverride = never
  • TToSnapshotOverride = never

Properties

_defaultFn: () => TPropValue | typeof noDefaultValue
_defaultValue: TPropValue | typeof noDefaultValue
_fromSnapshotProcessor?: (sn: unknown) => unknown
_isId: boolean
_setter: boolean | "assign"
_toSnapshotProcessor?: (sn: unknown) => unknown
_transform:
    | undefined
    | {
        transform: (
            original: unknown,
            model: object,
            propName: PropertyKey,
            setOriginalValue: (newOriginalValue: unknown) => void,
        ) => unknown;
        untransform: (
            transformed: unknown,
            model: object,
            propName: PropertyKey,
        ) => unknown;
    }
_typeChecker: undefined | TypeChecker | LateTypeChecker
$creationValueType: TPropCreationValue
$fromSnapshotOverride: TFromSnapshotOverride
$hasSetter: THasSetter
$isId: TIsId
$isRequired: TIsRequired
$toSnapshotOverride: TToSnapshotOverride
$transformedCreationValueType: TTransformedCreationValue
$transformedValueType: TTransformedValue
$valueType: TPropValue

Methods