Is there a possibility to use enums in neo-one smart contracts? I tried to declare an enum, but got the following 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.
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',
};