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

Serde tagging #328

Open
oscartbeaumont opened this issue Jan 21, 2025 · 1 comment
Open

Serde tagging #328

oscartbeaumont opened this issue Jan 21, 2025 · 1 comment

Comments

@oscartbeaumont
Copy link
Member

oscartbeaumont commented Jan 21, 2025

Right now specta_typescript always applies Serde tagging.

We investigated moving this process to specta_serde but that's not possible because Typescript is tagged by content while other languages are not. So you end up with something like:

Say you have enum T { A }. A is exported to TS as null by default but when you run it through specta_serde what does it become? You would think it goes from Fields::Unit to Fields::Unnamed(vec![ Field::new(DataType::Literal(LiteralType::String("A") ]). Now that's fine but then export that same typemap to Rust and you effectively get enum T { A("A") } which is not possible.

Should we make it configurable?

untagged in the equivalent of the approach we looked at for `specta_serde

Should we move tagging configuration to specta_typescript specific context? Well the Rust exporter should include the json tagging attribute so maybe this is just not possible, idk.

@oscartbeaumont
Copy link
Member Author

EnumRepr should probs be Option<EnumRepr> so specta_serde can adjust the default.

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

1 participant