rescript-webapi icon indicating copy to clipboard operation
rescript-webapi copied to clipboard

Canvas2D style type doesn't work as intended

Open TheSpyder opened this issue 3 years ago • 0 comments

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.

TheSpyder avatar Feb 03 '22 11:02 TheSpyder