Closed codeincarnate closed 1 year ago
interesting, thanks for the issue!
First, let's make sure we're on the same page on what you're trying to express with the input CUE. I interpret the intention behind this code:
cellOptions: TableCellOptions | *{ type: TableCellDisplayMode & "auto" }
// added these from original source for reference
TableCellDisplayMode: "auto" | "color-text" | "color-background" @cuetsy(kind="enum",memberNames="Auto|ColorText|ColorBackground")
as:
I want the
cellOptions
field of some larger schema to be an instance ofTableCellOptions
.
TableCellOptions
is a discriminated union with a tag/discriminator field namedtype
, which we want to express in TS as an enum.When receiving data for a schema containing this
cellOptions
field, if the data lacks acellOptions
field, thencellOptions
should be aTableCellOptions
of typeauto
, represented using the enum, and having no other field values.
Is that accurate?
Hey Sam, yes that's accurate. The main issue with the above is that the first output causes a type error as it's not explicitly a TableCellDisplayMode member (even though the string is a member of the enum).
It was fixed in the PR where we fixed the way to set the enums and it was useful to find another issues.
As a part of grafana/grafana#59363 ran into an issue in which using an enum member within a default field will emit the literal value for that enum as opposed to accessing the member.
For the following cue description:
this is emitted:
However, it's expected that this would be emitted instead: