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

fix: Fix optional enums in Nitrogen #130

Merged
merged 3 commits into from
Sep 16, 2024
Merged

fix: Fix optional enums in Nitrogen #130

merged 3 commits into from
Sep 16, 2024

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Sep 16, 2024

Fixes enum parsing by properly detecting the non-nullable type in unions.

This change now allows these APIs to work:

(event?: Type | TypeB)
(event: Type | TypeB)

Previously that broke.

@mrousavy mrousavy merged commit f317ea2 into main Sep 16, 2024
10 checks passed
throw new Error(
`String literal ${type.getText()} cannot be represented in C++ because it is ambiguous between a string and a discriminating union enum.`
)
return new StringType()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this up above with the isString() clause?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combining optionals with union doesn't always work
2 participants