InferLink
type InferLink<Cells> = Extract<CellArrayMember<Cells>, {
type: typeof LINK_MODEL_TYPE;
}>;
Infer the link record type from a cells collection, the link counterpart of
InferElement. Selects the member whose type is 'link'.
Type Parameters
| Type Parameter | Description |
|---|---|
Cells | the cells collection to infer from, usually typeof cells |
Example
import type { InferLink } from '@joint/react';
const cells = [
{ id: 'a', type: 'element', data: { label: 'A' } },
{ id: 'e', type: 'link', source: { id: 'a' }, target: { id: 'b' }, data: { weight: 2 } },
] as const;
type Edge = InferLink<typeof cells>; // link variant of the union
type EdgeData = InferLink<typeof cells>['data']; // { weight: 2 }