design patterns – How are discriminated unions (e.g. in TS) used in messaging schemes?

In the documentation about discriminated unions in typescript, here it says:

Discriminated unions are useful for more than just talking about
circles and squares. They’re good for representing any sort of
messaging scheme in JavaScript, like when sending messages over the
network (client/server communication), …

Could some explain an example of a messaging scheme that would make use of it?