Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type-safety of string based props #69

Open
davesnx opened this issue Nov 25, 2021 · 0 comments
Open

Improve type-safety of string based props #69

davesnx opened this issue Nov 25, 2021 · 0 comments

Comments

@davesnx
Copy link
Member

davesnx commented Nov 25, 2021

After the merge of #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:

  • Safety, within a string there could be a typo without noticing it.
  • Learnability. Users might be able to learn about HTML and their APIs.
  • Correctness, generate valid HTML does have a good impact on on-page SEO.

There have been a few efforts on rescript-react to push that direction but didn't land yet (a few comments by @dodomorandi in rescript-lang/syntax#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant