I would like to have constant (readonly) properties in a React.Component class. The problem is that I should not initialize them in the constructor since they trigger side effects like setInterval or fetch. Instead I should initialize them in componentDidMount but since I use strict type checkings I must also indicate their types can be undefined (or null, whatsoever). That s what I want to avoid because then I am forced to check if the value is not null every time I use it despite I know it already, and I also wanna avoid using the "!" operator as much as possible because then I don t have type errors when I forget to initialize them.
Does there exist a clean solution? Some way to tell typescript that componentDidMount is like a constructor and so a property can be initialized only there?