Rich content editor that stores a string, an array of custom records, or null.
type BardField<T extends BardFieldSet<{ type: string }> = BardFieldSet<{ type: string }>> =
(T extends BardFieldSet<infer U>
? U[]
: string) | null;
type property.type MyBardSets =
| BardFieldSet<{ type: "text"; text: string }>
| BardFieldSet<{ type: "button", label: string, url: string, }>
| BardFieldSet<{ type: "image", src: string, alt: string, }>;
type MyBardField = BardField<MyBardSets>;
// Result: string | null | MyBardSets[]
Structure for Bard set instances.
Will always require a type property.
type BardFieldSet<T extends (Record<string, any> & { type: string }) = (Record<string, any> & { type: string })> = {
type: string;
} & T;
type property.type MyBardSets =
| BardFieldSet<{ type: "text"; text: string }>
| BardFieldSet<{ type: "button", label: string, url: string, }>
| BardFieldSet<{ type: "image", src: string, alt: string, }>;