Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Render computed fields as their base type #75

@sdboyer

Description

@sdboyer

Currently, the following input:

Something: {
	foo: bool & bar == "someval"
	bar: string
} @cuetsy(kind="interface")

will be translated as follows:

export interface Something {
  foo: false; // this is the problem
  bar: string;
}

It's doing this because in non-concrete schema form, it's true that bar != "someval", even though it's still possible that a value could arrive later and make it true.

These kinds of computed fields are a very powerful use case for CUE, and we want to be able to use them in schema without messing up language codegen. It'd be great if cuetsy could be smart enough to figure this out on its own. Or, if there's too much ambiguity, we could consider introducing a hinting attribute like @cuetsy(asBase) to indicate to the analyzer that it should just render the TS type corresponding to the incomplete kind of the field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions