Coming from TypeScript, having an explicit discriminator field (like "type") is a lot easier to deal with[1] (which to be fair is compatible with the last example given in the OP where they have a "type" field and a generic "data" payload field).
[1] https://www.typescriptlang.org/docs/handbook/2/narrowing.htm...