-
Notifications
You must be signed in to change notification settings - Fork 119
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
Exporting enum discriminants #153
Comments
I'm in need of this also |
I thought I would need this but it turned out that the enum values are serialized to their string representation when sent as JSON response from axum. So I can use the literal string representation in the TypeScript code, Rust enum in rust code, and in the database the enum is stored as an integer. #[repr(i32)]
#[derive(Hash, Eq, Debug, PartialEq, sqlx::Type, TS, Serialize, Deserialize, Clone, Copy)]
#[serde(rename_all = "snake_case")]
#[ts(export)]
pub enum MyEnum {
Foo = 1,
Bar = 2,
} |
Duplicate of #23 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to export a struct that looks like this
into a format that looks like this:
This is what was generated:
Is there a way to get an enum in typescript with the same discriminants as in rust?
The text was updated successfully, but these errors were encountered: