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

Style guide #81

Open
tom-sherman opened this issue Jan 1, 2022 · 1 comment
Open

Style guide #81

tom-sherman opened this issue Jan 1, 2022 · 1 comment

Comments

@tom-sherman
Copy link
Contributor

This library will be far from "complete" at v1 due to many missing bindings, but also it will be forever expanding as the web platform expands.

Couple this with the fact that ReScript bindings are not simpl typed declarations to existing JS (a la lib.dom.d.ts), they are more new APIs that model the underlying platform. It makes the API decisions of this library more of a creative and subjective endeavour than it may be in TypeScript-land.

That's a lot of words to say that I think a style guide is valuable. It would:

  • Help to keep the API consistent as this library grows
  • Aid users in the discoverability of the API. If you know how a Web API works you should be able to intuit how rescript-webapi does it
  • Make lives easier for external contributors

Maybe we can use this issue as a starting point for what would be included in this documentation.

@tom-sherman
Copy link
Contributor Author

See #76 (comment)

I've taken different approaches for option bags depending on the optionality of the properties. My logic goes as follows:

  • If there is only one property, use an object type. Mark it as required even if the API accepts an empty object
  • If there is more than one property but they're all required, use an object type
  • If there is more than one property and one or more are optional, use an option bag module

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