Core
struct.literal
Struct that accepts exactly one boolean, null, number, or string value.
@defjs/core · Function
Signature
function literal<const T extends LiteralValue>( value: T, ): Struct<T, T>;
-
Accepts only
value. The comparison usesObject.is, so any other value fails withinvalid_literal. -
valuemust be aboolean,null,number, orstring. -
Use it for the tag field of struct.discriminatedUnion().
Parameters
Prop
Type
value T