lichess-org / chessground

Mobile/Web chess UI for lichess.org
https://lichess.org
GNU General Public License v3.0
1.02k stars 262 forks source link

Improve brush type #245

Closed qwerty084 closed 1 year ago

qwerty084 commented 1 year ago

brush in DrawShape is currently typed as string | undefined. Passing undefined to brush crashes when using setShapes(): Uncaught TypeError: brush is undefined (svg.ts:87) So it should be atleast string type.

I also added the available colors to the brush property, from state.ts. Because if you pass black as a string it just crashes. It would be nice if the available colors are in the type.

niklasf commented 1 year ago

Thanks!

Uncaught TypeError: brush is undefined (svg.ts:87)

Somewhere along the way the possibility of brush being undefined must have been ignored/lost, or else this error should have been caught at compile time. Let's fix that, too.

niklasf commented 1 year ago

Sorry for the delay. Merged now.

I also refreshed my understanding of the drawing code, and tweaked it a bit more: 8eef51cea368a1756e3fbaa327161e4f93b3dbca.