A discriminated union narrows correctly but the circle branch reads the wrong property.
Codetypescript
type Circle = { kind: "circle"; radius: number };
type Square = { kind: "square"; side: number };
type Shape = Circle | Square;
function area(shape: Shape): number {
if (shape.kind === "circle") {
return shape.side * shape.side;
}
return shape.side * shape.side;
}