@mocanvas/editor · type

ExtractShapeByProps

type ExtractShapeByProps<Props extends object> = {
    [Type in RegisteredShapeType]: Props extends Partial<TLGlobalShapePropsMap[Type]> ? Type : never;
}[RegisteredShapeType]

The registered shape types whose props include Props.

This is how a helper that only needs *part* of a shape stays honest: a "resize anything with a width and height" routine takes ExtractShapeByProps<{ w: number; h: number }> and gets every shape type that actually has them, instead of any or a hand-maintained union that forgets the custom shape someone added last week.

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.