Skip to content
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

Render computed fields as their base type #75

Open
sdboyer opened this issue Jan 13, 2023 · 0 comments
Open

Render computed fields as their base type #75

sdboyer opened this issue Jan 13, 2023 · 0 comments
Labels
kind/feature New feature or request

Comments

@sdboyer
Copy link
Contributor

sdboyer commented Jan 13, 2023

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.

@sdboyer sdboyer added the kind/feature New feature or request label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant