This is something that im still thinking how i will handle it.
The main idea is that it would work like typescript unions so you can save more than 1 type of data within the same document.
However this brings some new issues to the table, those being:
- Handling union validation
- How do you know which union you are validating
- Handling parsing
- Same as validation but for parsing back into a js object
So the other option we have is to add a depends property.
With this you could say that a property only exists if said boolean is true, habdling this at runtime would be extremely simple leaving only the type-level stuff to worry.
In the type level it would create a union for the depends to reflect this exact case, however thats a little complicated and needs some experimentation to achieve the desired result without having to remake all the types, all we want is to update the type that does initial parsing since if it returns a union all other types should handle it properly, if doing so causes issues then the only type that should be changed is the mapping type, which now that im writting this might make more sense... we will see how it goes since this is more of an idea that could improve the user experience than something that is actually needed.
This is something that im still thinking how i will handle it.
The main idea is that it would work like typescript unions so you can save more than 1 type of data within the same document.
However this brings some new issues to the table, those being:
So the other option we have is to add a
dependsproperty.With this you could say that a property only exists if said boolean is true, habdling this at runtime would be extremely simple leaving only the type-level stuff to worry.
In the type level it would create a union for the depends to reflect this exact case, however thats a little complicated and needs some experimentation to achieve the desired result without having to remake all the types, all we want is to update the type that does initial parsing since if it returns a union all other types should handle it properly, if doing so causes issues then the only type that should be changed is the mapping type, which now that im writting this might make more sense... we will see how it goes since this is more of an idea that could improve the user experience than something that is actually needed.