xxxxxxxxxx
function isCircle(shape: Shape): shape is Circle {
return shape.kind === 'circle';
}
function isRect(shape: Shape): shape is Rect {
return shape.kind === 'rect';
}
// now you get Circle[] type inferred correctly
const circles = myShapes.filter(isCircle);