-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(gen): const from default #7
Conversation
Generates a matching const for each type definition that holds the defaults fot the type based on information from CUE defaults.
excellent! 2 questions:
|
Hard-disables defaults generation for list fields of structs. We don't allow `[...number] | *[1,2]` anyways, so this does not take anythinga way, but prevents `[]` all over the place
The results here look great! If it is possible to optionally tag interfaces that we want to generate a default that would be best -- for most types we do not want a default and it will just create noise bloat. It is only the final full options objects where we want. Perhaps:
|
So, months later... i'm trying to recall why it is that we thought struct representations of enums were a good idea. I think it was because we were looking for a way to encode arbitrary member names easily. But it's just wrong. CUE structs are plainly, not analogous to a TS enum. In a system (like we have in Grafana), using the CUE struct representation directly in some larger CUE structure means that you'll end up with a struct type on the CUE side, and an enum on the TS side. Not what we want. The rest of this looks good, but i think that part's just not what we need. i introduced an alternative pattern that seems like it should give us the same control (even if it's a bit awkward), while having a CUE type (simple disjunct value) which is harmonious with the TS it will become. |
Well, it was literally the first issue - #1. Not the fault of this PR. So i'm gonna merge this one as-is, then we can pull that behavior out. |
Generates a matching const for each type definition that holds the defaults for the type based on information from CUE defaults.
Status: Useful (I guess)