typeshare icon indicating copy to clipboard operation
typeshare copied to clipboard

Allow to generate unions instead of TS enums in Typescript

Open akozhemiakin opened this issue 2 years ago • 1 comments

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";

akozhemiakin avatar Sep 27 '23 09:09 akozhemiakin

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

Tehnix avatar Feb 14 '25 22:02 Tehnix