Satisfying TS

I see as used a lot in TypeScript, and it is one of my pet hates. It throws away type checking by asserting “I know better than the compiler”, which is often not true. A common case is filtering a discriminated union array down to one variant. Say you have a chat app, people reach for an assertion like this: type UpdateNewMessage = { type : "UpdateNewMessage" ; text : string }; type…