@mocanvas/editor · type

SetValue

type SetValue<Set extends {
    [key: string]: unknown;
} | readonly unknown[]> = Set extends readonly unknown[] ? Set[number] : Set[keyof Set]

The union of the values of a const object or array.

``ts const KINDS = { a: "a", b: "b" } as const type Kind = SetValue<typeof KINDS> // "a" | "b" ``

Used throughout the record layer so a closed set is declared once, as a value, and the type is read back off it — rather than being written twice and drifting.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.