@mocanvas/editor · type
type Shape<Type extends string = RegisteredShapeType> = [RegisteredShapeType] extends [never] ? UnknownShape : Type extends string ? BaseShape<Type, ShapePropsForType<Type>> : neverOne shape record, with its props resolved from TLGlobalShapePropsMap.
With no argument this is the union of every REGISTERED shape type, and the
conditional distributes over that union — so Shape is discriminated and
shape.type === "note" narrows shape.props to the note's props.
Registered types only, deliberately: an open string member would be
assignable from every literal and would survive the narrowing, defeating the
whole point. For a shape whose type is not known statically, use
UnknownShape. Until something registers a type — @mocanvas/editor
on its own ships no shapes — this falls back to UnknownShape so the
package is usable alone.
Mentioned here
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.