ml-in-barcelona / jsoo-react

js_of_ocaml bindings for ReactJS. Based on ReasonReact.
https://ml-in-barcelona.github.io/jsoo-react
MIT License
138 stars 19 forks source link

Improve type-safety of string based props #69

Open davesnx opened 2 years ago

davesnx commented 2 years ago

After the merge of https://github.com/ml-in-barcelona/jsoo-react/pull/66, the code has full control over the types of makeProps. Many props are defined as string when in reality (the HTML spec) doesn't allow any string and defines an enum or some sort of combination. It might happen to some props that are defined as int or bool as well.

The benefit from moving away from string-based API are:

There have been a few efforts on rescript-react to push that direction but didn't land yet (a few comments by @dodomorandi in https://github.com/rescript-lang/syntax/pull/235) and I'm not sure if there's a positive intent to do so.

We have the possibility to do it.

Other references:


The plan for this is to check TyXML and https://html.spec.whatwg.org/#global-attributes and manually ensure that most of our attributes make sense.

Further investigations are on my plate, where I might try to change the html.ml list of attributes into per-element basis and ensure that the generated HTML from React components is valid.