What is is the best way to declare a constant in a TypeScript class
?
相关问题
- Angular RxJS mergeMap types
- void before promise syntax
- Ignore Typescript errors in Webpack-dev-server
- What uses more memory in c++? An 2 ints or 2 funct
- Angular: ngc or tsc?
相关文章
- Cannot find module 'redux' 怎么解决?
- How to get a Component's own ElementRef for re
- 'Pick' only refers to a type, but is being
- Why does `keyof any` have type of `string | number
- React testing library: Test attribute / prop
- TypeScript - Puppeteer library error: “Cannot find
- How to reference type of self in Typescript interf
- React and typescript with webpack typing issue
You can't declare a constant, you can declare a
readonly
field, which is weaker then what you would expect from a constant but might be good enough:I say it's weaker because at runtime the value can be changed, and more over even within the type system we can violate
readonly
without a type assertion:If you can I would stick with a regular
const
declaration outside the class.