-
Notifications
You must be signed in to change notification settings - Fork 37
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
Change fetch method
to a string
#65
base: main
Are you sure you want to change the base?
Conversation
I'm a little on the fence about this one. While yes the variant wrapper is somewhat of a type flex, it's also nice to have the compiler guarantee that if the method needs to be set, for the vast majority of use cases the string is spelt correctly. Could we make the default I'm adding this to the 2.0 release since it's a breaking change. I might start a feature branch for 2.0 so we aren't leaving your PRs open for months; one of the nice things about the way ReScript compiles is dependencies can point to a git branch instead of NPM and still work perfectly. |
@TheSpyder I'm not sure this would work with |
ok, fair point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we had convenience functions for common methods like makePost, makeGet, makeDelete some of those could also skip having a body property since you can't send that into a get request for example and it would also avoid the weird case where method is a poly variant as input and a string as a property on the object.
It would make the bindings a bit larger since all the properties would have to be duplicated between these functions. Not sure if it's worth it though since having the wrong method will likely not be missed if you make any form of rest api call since it will simply not work.
Huh, TIL the fetch API enforced that. It's not something that bs-fetch or TypeScript enforces - I'm guessing because it's pretty difficult to make that mistake without your program not working as you mention. |
I haven't forgotten about this, but we're getting fairly close to a 1.0 release candidate. Once I'm happy 1.0 is stable (it won't release until ReScript 10 does) I'll make a 2.0 branch and we can start merging PRs like this one to experiment with API changes. |
1.0 seems fairly stable but it might be another month before I have time to start the 2.0 branch. Work has been too busy in the lead up to TinyMCE 6.0 to spend any time on this, and I've had a log of personal stuff to deal with so I can't make time in the evenings for it. |
Sorry for letting this sit idle for so long. I've had a very busy time both in work and personal life. ReScript v10 hit alpha today, so I'll make time soon to wrap up the planned activities in version 1.0 and we can begin breaking APIs in earnest while we play with the new features. |
fe0f2e9
to
7f2cf0a
Compare
Relates to #30 and #38
The variant here wasn't gaining any extra type safety and introducing a cost to the bindings where none was needed.
method
accepts any arbitrary string and while it's true that some HTTP methods are specced to be in uppercase, the fetch API will normalise them for you.