Typescript, Typescript With React, Programming, JavaScript, Technology.
property, TypeScript can intelligently narrow down types. Consider an example: type Shape = { kind: "circle"; radius: number } | { kind: "rectangle"; width: number; height: number }; function getArea(shape: Shape): number { switch (shape.kind) { case "circle": return Math.PI * shape.radius ** 2;