Open
Description
I found several places where we are accessing nullable properties in an unsafe way. A few of these were reported automatically through Sentry with type errors like Cannot read property 'rotationCenter' of null
.
Drawable.js (mostly accessing properties of the skin without checking it exists)
- https://github.com/LLK/scratch-render/blob/8495c6c4e2bbb18a6637d3786db89e8b8070ab62/src/Drawable.js#L311-L318
- https://github.com/LLK/scratch-render/blob/8495c6c4e2bbb18a6637d3786db89e8b8070ab62/src/Drawable.js#L209
- https://github.com/LLK/scratch-render/blob/8495c6c4e2bbb18a6637d3786db89e8b8070ab62/src/Drawable.js#L217
@rschamp @cwillisf We tend to do this a lot in other repos (probably more than here, i'm not picking on render at all). It is a language trap that javascript lets you fall in easily and we aren't linting it (i'm not sure that is even possible?). Are there any design patterns we should think about that would help us from doing this type of thing?