Why does my enum assign a wrong integer in a TypeScript class?

I have an enum declared as follows:

public enum ProductSku { NotSet = 0, CPO2D = 1, CPO3D = 2 CPO2Ds = 3, etc etc } 

Edit: Now I see that the TypeScript definition for ProductSku was wrong, it looked like this:

 export enum ProductSku { CPO2D = 0, CPO3D = 1, CPO2Ds = 2, CPO3Ds = 3, CPOComplete = 4, NotSet = 0, } 

As you can see, I assigned 1 to CPO2D, but when I use it in the TypeScript class, it has a value of 0 (see screenshot below)

Screenshot in Visual Studio:

Screenshot on hover in Visual Studio

What i tried

I saved everything, rebuilt the project, and also closed and reopened Visual Studio

I changed CPO2D to CPO2Ds (expecting the value to be 3 ), which is assigned 2

This may be a very simple explanation, but I don’t see what I am doing wrong ...

+7
enums c # typescript
source share

No one has answered this question yet.

See related questions:

1609
What is TypeScript and why will I use it instead of JavaScript?
1476
Hidden features of C #?
441
What are enumerations and why are they useful?
347
Why is an enumeration class preferable to a simple enumeration?
4
Is there a way to create enums in typescript that are ambient?
3
Typescript const Enum isue
one
Is there a way to get the integer value of an enumeration in visual studio while the program is not running?
0
Unexpected behavior with enumeration values ​​as types (in typescript)
0
Wikipedia 2 listing links between interfaces and classes
0
TypeScript 1.6.2 & # 8594; Cannot convert type '' to type '': type '' is an enumeration and can only be assigned from the same enumeration type or number

All Articles