ObjectStruct
Object-shaped struct type produced by struct.object(shape).
@defjs/core · Type
Signature
interface ObjectStruct<T extends ObjectShape> extends StructMethods<ObjectInput<T>, ObjectOutput<T>, false>, StructLike<ObjectInput<T>, ObjectOutput<T>, false> { readonly _struct: ObjectStructTypes<T>; null(): PreservedStruct< ObjectStruct<T>, ObjectInput<T> | null, ObjectOutput<T> | null, false >; nullable(): PreservedStruct< ObjectStruct<T>, ObjectInput<T> | null, ObjectOutput<T> | null, false >; nullish(): PreservedStruct< ObjectStruct<T>, ObjectInput<T> | null | undefined, ObjectOutput<T> | null | undefined, true >; optional(): PreservedStruct< ObjectStruct<T>, ObjectInput<T> | undefined, ObjectOutput<T> | undefined, true >; }
Fields are required by default. A field marked optional() or nullish() becomes an optional key, so field presence follows those modifiers. Unknown keys are stripped when parsing. Wire names can differ from TypeScript keys via .alias(). A failed parse returns [StructError, undefined]. ObjectInput, ObjectOutput, ObjectStructTypes, and PreservedStruct are internal helper types.
Members
Prop
Type
_struct ObjectStructTypes<T>Phantom payload. optionalOut is true only when this struct's output fields may be absent.
null () => PreservedStruct<ObjectStruct<T>, ObjectInput<T> | null, ObjectOutput<T> | null, false>Allow null in addition to the current input and output types.
nullable () => PreservedStruct<ObjectStruct<T>, ObjectInput<T> | null, ObjectOutput<T> | null, false>Alias for StructMethods.null.
nullish () => PreservedStruct<ObjectStruct<T>, ObjectInput<T> | null | undefined, ObjectOutput<T> | null | undefined, true>Allow null or undefined, marking the field optional in object output.
optional () => PreservedStruct<ObjectStruct<T>, ObjectInput<T> | undefined, ObjectOutput<T> | undefined, true>Allow undefined, marking the field optional in object shapes.
alias (name: string) => ObjectStruct<T>Override the external wire name for this field without changing the TypeScript property name.