quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

Missing enum key from typescript string enums

Open 9bic opened this issue 6 years ago • 1 comments

I tried to convert from typescript with TS string enums, not returns enum keys. When enum values are string, returns key correctly. It seems that when enum values passes parseInt(), return The${value}.

convert

quicktype --src enum.ts --lang typescript --out out.ts --just-types

enum.ts

enum TestEnumWithString {
  Foo = "foo",
  Bar = "bar",
  Baz = "baz"
}

enum TestEnum {
  Foo = "000",
  Bar = "001",
  Baz = "002"
}

out.ts

NOTE: I also tried to convert to Swift, and got similar result

export enum TestEnumWithString {
    Bar = "bar",
    Baz = "baz",
    Foo = "foo",
}

export enum TestEnum {
    The000 = "000",
    The001 = "001",
    The002 = "002",
}


9bic avatar Jan 17 '19 11:01 9bic