After updating typings to @types/ 16.4.4. we got set of these errors:
error TS2540: Cannot assign to 'state' because it is a constant or a read-only property.
The code that was broken:
constructor(props) {
super(props);
this.state = {
stateProperty: initialValue
}
}
The fix is to use
constructor(props) {
super(props);
this.setState({
stateProperty: initialValue
});
}
Previous version we used was @types/ 16.0.40
ReadOnly property should be allowed to set in a constructor.
Authors: @johnnyreilly, @bbenezech, @pzavolinsky, @digiguru, @ericanderson, @morcerf, @tkrotoff, @DovydasNavickas, @onigoetz, @theruther4d, @guilhermehubner, @ferdaber, @jrakotoharisoa
After updating typings to @types/ 16.4.4. we got set of these errors:
error TS2540: Cannot assign to 'state' because it is a constant or a read-only property.
The code that was broken:
The fix is to use
Previous version we used was @types/ 16.0.40
ReadOnly property should be allowed to set in a constructor.
Authors: @johnnyreilly, @bbenezech, @pzavolinsky, @digiguru, @ericanderson, @morcerf, @tkrotoff, @DovydasNavickas, @onigoetz, @theruther4d, @guilhermehubner, @ferdaber, @jrakotoharisoa