ExtractShapeByProps

See source code

Extract a shape type by its props.

This utility type takes a props object type and returns the corresponding shape type from the TLShape union whose props match the given type.

type ExtractShapeByProps<P> = Extract<
  TLShape,
  {
    props: P
  }
>

Example

type MyShape = ExtractShapeByProps<{ w: number; h: number }>
// MyShape is now the type of shape(s) that have props with w and h as numbers
Prev
TLUiTranslationKey
Next
RecordProps