"const" in generated enum definition causes compiler error

Issue #98 invalid
Mattijs Perdeck
created an issue

The C# definition:

namespace dtos
{
    public enum Color
    {
        Black = 55,
        Green,
        Blue,
        Red = 78
    }
}

is translated to:

declare module dtos {
    export const enum Color {
        Black = 55,
        Green = 56,
        Blue = 57,
        Red = 78
    }
}

However, when trying to compile this, the compiler (tsc) generates this error message:

error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.

This error message goes away when you manually remove the "const" from the generated definition:

export enum Color {
    ...
}

Comments (4)

  1. mortb1

    The const enums where added to typscript in v1.4. My guess is that the error will go away if you update typescript.

    You may also generate enums without "const", take a look at: #96

  2. Log in to comment