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

Supporting algebraic enums without the content attribute #141

Open
FlorianDenis opened this issue Aug 30, 2023 · 1 comment
Open

Supporting algebraic enums without the content attribute #141

FlorianDenis opened this issue Aug 30, 2023 · 1 comment

Comments

@FlorianDenis
Copy link

FlorianDenis commented Aug 30, 2023

I realize this is something that is not currently supported; This is something that would hugely increase the benefit of this tool for me.

To be clear, I am talking about

#[typeshare]
#[derive(Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum MyEnum {
    A,
    B {
        field1: String,
        field2: u32,
    },
}

which I would like to have generated (in TS for instance) as

type MyEnum =
    | { type: "a" }
    | { type: "b", field1: string, field2: number }

I want to dig a bit more into the reasons why this choice was made and how we could potentially move forward.

Was this not added because:

  1. You tried to implement it and encountered roadblocks?
  2. You have no use internally for it? In which case, would you be open to contributions allowing this? This would not necessitate a major version bump right, this would just be a non-breaking addition on the current features, or am I missing something ?
@FlorianDenis
Copy link
Author

To support the idea, I started working on a draft implementation supporting all languages but Go: see #142

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