Skip to content

Allow to generate unions instead of TS enums in Typescript#145

Open
akozhemiakin wants to merge 1 commit into
1Password:mainfrom
akozhemiakin:union-enums
Open

Allow to generate unions instead of TS enums in Typescript#145
akozhemiakin wants to merge 1 commit into
1Password:mainfrom
akozhemiakin:union-enums

Conversation

@akozhemiakin

@akozhemiakin akozhemiakin commented Sep 27, 2023

Copy link
Copy Markdown

Resolves #35

Now for unit enums, you can choose to generate a TypeScript union type instead
of a TypeScript enum.

#[typeshare(ts_union)]
pub enum UnitEnum {
    VariantA,
    VariantB,
    VariantC,
}

This would generate the following TypeScript code:

export type UnitEnum = "VariantA" | "VariantB" | "VariantC";

@Tehnix

Tehnix commented Feb 14, 2025

Copy link
Copy Markdown

Any chance of reviving this? If there's interest in getting this merged I wouldn't mind taking a look at it

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.

Support for generating TypeScript union types for non-algebraic enums

2 participants