Open n1ru4l opened 4 years ago
This is hard because we don't control the actual execution. If we do - then there is a way to make the resolution of an abstract output type to require the Value and its Object Type that it maps to.
Then you don't even need "resolveType" or "isTypeOf" at all!
Here is an example of how to implement that idea:
For interfaces, the best thing to do is using
isTypeOf
.E.g.
With a library such as
io-ts
the stuff can be even "more" save:The drawback of this is, that the type-safety does happen while executing the code not while compiling it. I wonder whether there are other solutions worth exploring.
For a union type we have the same "issue":
I mentioned some more stuff related to this in https://github.com/sikanhe/gqtx/issues/9