To start TypeScript numeric enum
from 1
instead of the default 0
, you simply need to specify 1
as the initializer for the first member in the enum
. All members that follow are auto-incremented from that point on.
For example:
enum FooNum { A = 1, B, C, } console.log(FooNum.A); // 1 console.log(FooNum.B); // 2 console.log(FooNum.C); // 3
Hope you found this post useful. It was published . Please show your love and support by sharing this post.