1 already defined in Enum

var STATE = cc.Enum
        ({
            ERROR: -1,
            OK: 0,
            STATE_ONE: 1
        }),

It show up an error: 1 already defined in Enum, seem like I can’t use negative number in the enum.
I’m porting codes from another project (of other team in my company), which already completed and the server shouldn’t be changed. Are there any flags in Cocos Creator to solve this problem?

Thank you.

Based on cc.Enum description:

If a enum item has a value of -1, it will be given an Integer number according to it’s order in the list.
Otherwise it will use the value specified by user who writes the enum definition.

var WrapMode = cc.Enum({
	    Repeat: -1,
	    Clamp: -1
});
	// Texture.WrapMode.Repeat == 0
	// Texture.WrapMode.Clamp == 1
	// Texture.WrapMode[0] == "Repeat"
	// Texture.WrapMode[1] == "Clamp"

In your case:

STATE.ERROR == 0
STATE.OK == 0
STATE.STATE_ONE == 1

Here is my test case:

var test = cc.Enum({
            A: -1,
            B: 0,
            C: 1
        });
        console.log(test.A);    // 0
        console.log(test.B);    // 0
        console.log(test.C);    // 1

I have encountered the same problem a while ago, you can assign string to the properties in enum, then use parseInt to convert back to integer when needed

see https://mrsmellypotato.wordpress.com/2019/04/02/negative-value-in-enum/