Actyx / machines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prohibit non-serializable properties on Event design

Kelerchian opened this issue · comments

Event passes through serialization and gets transported outside of the JS runtime boundary. It means utilizing JSON native utilities. JSON.serialize and JSON.parse is not bijective for all available data types in JS. There are also

For example:

  • JSON.stringify serializes a Date object into a string (e.g. 2023-03-20T11:54:20.110Z), but JSON.parse does not parse it back into a Date object
  • JSON.stringify serializes functions and symbols into undefined
  • JSON.stringify serializes any Map and Set into an empty object
  • JSON.stringify throws an exception when a conversion of BigInt is attempted

The acceptance criteria for this issue are:

  • Event.design(_).withPayload<> function should not be able to receive values that does not work perfectly with JSON.serialize/JSON.parse
  • Errors from invalid payloads must be catchable by TS' compiler

Solved in #7