Deviopath › TypeScript

Shape Area

Medium · Discriminated Unions

A Shape is a circle, a square or a rectangle. The kind property tells you which one it is.

Write area(shape: Shape): number. Use Math.PI for circles.

Next: Result Type for Safe Division