Skip to content

Is it possible to generate numeric enums? #140

@ottosson

Description

@ottosson

Hi. thanks for this awesome library!

Is it possible to generate numeric enums in typescript from my rust enums?

#[derive(Serialize, Deserialize, TS, Debug)]
#[serde(rename_all = "camelCase")]
#[ts(export, export_to = "../src/types/interfaces/")]
pub enum PlotType {
  Display = 0,
  Extents = 1,
  Limits = 2,
  View = 3,
  Window = 4,
  Layout = 5,
}

becomes

export type PlotType = "display" | "extents" | "limits" | "view" | "window" | "layout";

I would expect it to become something like

export const enum PlotType = {
  Display = 0,
  Extents = 1,
  Limits = 2,
  View = 3,
  Window = 4,
  Layout = 5,
}

Is this possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions