quicktype
quicktype copied to clipboard
Missing enum key from typescript string enums
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",
}