Because it discriminates on type, if (cell.type === 'element') narrows
correctly inside arrays and hooks. For mixed built-in shape arrays with typed
data, build the union yourself:
ElementRecord<MyData, 'standard.Rectangle'> | LinkRecord<MyData, 'standard.Link'>.
One cell — either an ElementRecord or a LinkRecord — as a discriminated union on
type:type === 'element'→ ElementRecordtype === 'link'→ LinkRecordBecause it discriminates on
type,if (cell.type === 'element')narrows correctly inside arrays and hooks. For mixed built-in shape arrays with typed data, build the union yourself:ElementRecord<MyData, 'standard.Rectangle'> | LinkRecord<MyData, 'standard.Link'>.