I think this is solved more generally with a discriminated union in typescript.
A state machine is the wrong solution unless you also need to restrict transitions themselves in my opinion
A state machine is the wrong solution unless you also need to restrict transitions themselves in my opinion
If a TS typed switch statement, say, offers the same guarantees of covering all options yet is just run of the mill JS that anyone can read and instantly grok, and covers 99% of usecases in run of the mill web dev product work, then to me that's an argument that it's the better solution.