Are there Enums in Neo-One Smart Contracts?

Viewed 42

Is there a possibility to use enums in neo-one smart contracts? I tried to declare an enum, but got the following error:

error

This is how I declared it:

enum testEnum{
  a,
  b,
  c,
}

export class Token extends SmartContract {
  private t: testEnum = testEnum.a;
}

It seems that not all typescript types are supported, or I declared it wrong.

1 Answers

The NEO•ONE TypeScript Smart Contract compiler actually does not currently support enums, which is why you are getting that error. When the compiler runs into an enum declaration (via the enum keyword) it just reports an unsupported syntax error. So I recommend just using a plain JS "object" to accomplish the same thing. Like this:

const testEnum = {
   a: 'a',
   b: 'b',
   c: 'c',
};
Related