How to implement class constants?

后端 未结 8 1861
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-22 17:40

In TypeScript, the const keyword cannot be used to declare class properties. Doing so causes the compiler to an error with \"A class member cannot have the \'co

8条回答
  •  我在风中等你
    2020-12-22 18:34

    Either use readOnly modifier with the constant one needs to declare or one might declare a constant outside the class and use it specifically only in the required class using get operator.

提交回复
热议问题