continuing from #11
Perhaps the only safe way to use serialize and getUniqueIdentifier is with type transformers? (e.g., similar to https://github.com/woutervh-/typescript-is)
Just like that library is able to create guardclauses on the fly, we should be able to figure out what the domain object is without requiring it to be instantiated. (i.e., the only purpose of instantiation becomes typechecking).
--
this would really be the only always safe way to use serialize and getUniqueIdentifier - as we'd never throw an error.
perhaps we should probably implement this change and require custom transformer be used if they want to user serialize or getUniqueIdentifier, as it will end up failing while passing type checking otherwise - which is not ideal?