Enums as strings in TypeScript

According to this post, as of ServiceStack 5.2 it is possible to generate enums as strings for TypeScript.
I was wondering if it is a bug/logical reason that the generation does not work for enumerations that do not start with a 0 value or enumerations that are not sequential.

For example:
public enum SomeEnum { Type1 = 1, Type2 = 2 }

public enum SomeEnum { Type1 = 0, Type2 = 4 }

Will not generate stringized enums but the next snippet will:
public enum SomeEnum { Type1 = 0, Type2 = 1 }

What is the advised way to support enumerations in typescript when dealing with enums that don’t contain the value 0 or are nog sequential?

These are equivalent:

public enum SomeEnum { Type1, Type2 }
public enum SomeEnum { Type1 = 0, Type2 = 1 }

If you use non-default sequential integer values it assumes their integer values are supposed to be preserved so the generated enums includes them which would otherwise be lost.

The recommendation would be to not specify them on your DTOs if you don’t want them included which is otherwise confusing but you could force the values to be lost with a DTO Type generation customization filter, i.e:

TypeScriptGenerator.PreTypeFilter = (sb, type) => {
    if (type.IsEnum == true)
        type.EnumValues = null;
};