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

Improve TS support for enums #221

Open
oscartbeaumont opened this issue Mar 12, 2024 · 1 comment
Open

Improve TS support for enums #221

oscartbeaumont opened this issue Mar 12, 2024 · 1 comment

Comments

@oscartbeaumont
Copy link
Owner

oscartbeaumont commented Mar 12, 2024

If you export an enum from Rust it's possible to provide values for multiple variants on the frontend due to the fact that | is typescript is not exclusive or.

I don't think this is a problem with adjacently tagged enums.

This article is a good rundown: https://effectivetypescript.com/2021/11/11/optional-never/

Eg. this demo needs to not compile:

const a: /* Specta output */ { a: string } | { b: string } = {
  a: "abc",
  b: "cde"
};

I think we would have Specta generate { a: string; b: never; } | { a: never; b: string; } instead which would cause the appropriate errors.

For personal reference this came up with search.paths in SD.

@oscartbeaumont oscartbeaumont changed the title Improve TS support for untagged enums Improve TS support for enums Mar 12, 2024
@JerwuQu
Copy link

JerwuQu commented Apr 25, 2024

Just stumbled into this. Would be very nice to have this feature!

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

No branches or pull requests

2 participants