You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For BType, the exported const would need to traverse the reference to AType to figure out the right default value for the exported const's Composed field.
Also, related, we can't assume that even required fields will have a default. I believe that means that the exported const isn't actually guaranteed to satisfy the exported interface. (That may just be more of an oddity than problematic, though).
In general, though, we don't need this to cover all possible CUE constructions perfectly, as an operating assumption in cuetsy, at least for now, is that folks are going to be checking the generated TS on the other side, and they can choose to rewrite their CUE if it doesn't come out right. (Yup, we iz prototyping!)
The text was updated successfully, but these errors were encountered:
Problem
Currently, we disregard CUE default values. This needs to change, though there's some flexibility here on exactly how we do it.
Proposed Solution
@ryantxu can say more about exactly how he thinks this ought to be shaped, but...
We should optionally generate:
const
with default values assigned for the type<typename>setDefaults(t <typename>)
*isDefault()
func that checks whether an instance of the type equal has the default values.Simple example:
i feel like there's probably a more elegant generic way of expressing the funcs, maybe even the default, perhaps leveraging some Partials. 🤷
This will be tricky. For one, i think we'll have to read through CUE references in a way we don't now. e.g.:
For
BType
, the exported const would need to traverse the reference toAType
to figure out the right default value for the exported const'sComposed
field.Also, related, we can't assume that even required fields will have a default. I believe that means that the exported const isn't actually guaranteed to satisfy the exported interface. (That may just be more of an oddity than problematic, though).
In general, though, we don't need this to cover all possible CUE constructions perfectly, as an operating assumption in cuetsy, at least for now, is that folks are going to be checking the generated TS on the other side, and they can choose to rewrite their CUE if it doesn't come out right. (Yup, we iz prototyping!)
The text was updated successfully, but these errors were encountered: