I believe, this could improve the developer experience of creating bindings because better error messages can be displayed (in the past I got some error messages in the browser that were quite cryptic to me, when binding to React components).
This probably also would lead to finding bugs earlier, that otherwise maybe would sneak into production.
A debug mode would make the build process a bit more complicated, because now there would be two build types, but I believe it would be worth it.
we do have a debug mode for showing values nicely.
I had some ideas for data validation for bindings, the challenge is that such data validation could only be done in the best effort, no guarantee could be provided
Is this documented somewhere? I could find anything.
the challenge is that such data validation could only be done in the best effort, no guarantee could be provided
Yes, no guarantees could be given. But for example, if we have:
@val external foo: int => int = "foo"
ReScript could assert in debug mode that foo returned an int and if not, show a nice error message or warning. If the return value of foo is passed around, that could lead to runtime errors that are not obvious, I think.
ReScript also could check at runtime if foo really exists (at module level, so errors would be shown directly after startup).
There are probably more scenarios like these where the compiler would be able to generate better error messages or warnings.
These checks couldn’t guarantee that the bindings are correct and would be a little like lints, but I think some help or some improved error messages are better than none.