TypeScript, Discriminated Unions, and the “as” Prop Problem
If you’ve been working with TypeScript for a while, you’ve probably run into situations where the compiler feels a little too conservative. One common case is when working with discriminated unions and destructuring.
It looks neat at first glance:
type Action =
| { kind: 'A'; payload: number }
| { kind: