TheSpyder / rescript-webapi

ReScript bindings to the DOM and other Web APIs
http://tinymce.github.io/rescript-webapi/api/Webapi/
Other
149 stars 36 forks source link

Canvas2D style type doesn't work as intended #95

Open TheSpyder opened 2 years ago

TheSpyder commented 2 years ago

https://github.com/tinymce/rescript-webapi/blob/55f4010c35c6b1f1c9301ba3e47120dacdb5587a/tests/Webapi/Canvas/Webapi__Canvas__Canvas2d__test.res#L27-L37

In this context, s is not a string. The compiler requires it to be gradient. It also requires the _ of the third match to be a gradient. It warns if there are not 3 patterns in the switch statement, but the second element in the tuple of all 3 take on the variable type of the first. This can be proven by swapping the first and second patterns, which then fails because g is not a string.

I like the idea of using a witness type but this seems to be unusable.