Prohibit non-serializable properties on Event design
Kelerchian opened this issue · comments
Alan Darmasaputra commented
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 aDate
object into a string (e.g.2023-03-20T11:54:20.110Z
), butJSON.parse
does not parse it back into aDate
objectJSON.stringify
serializes functions and symbols intoundefined
JSON.stringify
serializes anyMap
andSet
into an empty objectJSON.stringify
throws an exception when a conversion ofBigInt
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
Alan Darmasaputra commented
Solved in #7