-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typed data must carry type information #3
Comments
I think it would make sense to generate a type identifier field for every record type that is going to be included with each instance. That would have several benefits:
|
At the moment if you define types with a following signatures:
Then type union interprets
data
value not always as one would expected:Most likely in last statement
data
field was expected to be an instance ofY
instead ofX
, although given that{y: 2}
can be read both asX
andY
it was interpreted as a first type in the unionX
. While this is bad (see #2) it does not seem to be a common issue in my experience.What happens far more often in my experience is that new type is defined which supposed to be added to a type union (but for whatever reasons it was not added to type union):
Now surprise and a problem is far worse in this case, as passed
data
field had a type but it got casted to a completely different type. There is also no simple way to avoid or spot this issue.The text was updated successfully, but these errors were encountered: