melange-community / melange-fetch

Fetch bindings for Melange
MIT License
203 stars 53 forks source link

`Fetch.Response._type` should access the `type` property #33

Closed anmonteiro closed 4 years ago

anmonteiro commented 4 years ago

as per https://developer.mozilla.org/en-US/docs/Web/API/Response/type

agarwal commented 4 years ago

Would type_ be a better name for this over _type? Variables beginning with an underscore have special meaning by the OCaml compiler. They are allowed without triggering a warning if the variable is unused. That doesn't affect this PR directly, but might be better to avoid clashing with that convention.

glennsl commented 4 years ago

Would type_ be a better name for this over _type?

Yeah, I think it would. At the time this was written the convention was to use leading underscore because BuckleScript used (and in some cases still uses) that to be able to reference reserved keywords in JS interop. That convention has since changed, for exactly the reason you explain and because there are better ways of dealing with this now. However, even after fixing this here is unfortunately still one case where it needs to be used, as fixing that would require a major overhaul of the API (which wouldn't be a bad idea in itself, but I certainly don't have time to do it).

Anyway, I'll fix this one here and now while we're at it. Thanks for the heads up!