Skip to main content
Version: 4.3

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 ParameterDescription
Cellsthe 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 }

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub