TheSpyder / rescript-webapi

ReScript bindings to the DOM and other Web APIs
http://tinymce.github.io/rescript-webapi/api/Webapi/
Other
149 stars 36 forks source link

Webapi.FormData.t should not be a record type #84

Closed yawaramin closed 2 years ago

yawaramin commented 2 years ago

It is currently defined as:

type t = private {
  keys: Webapi__Iterator.t<string>,
  values: Webapi__Iterator.t<EntryValue.t>,
  entries: Webapi__Iterator.t<(string, EntryValue.t)>,
}
...
@send external keys: t => Webapi__Iterator.t<string> = "keys"
@send external values: t => Webapi__Iterator.t<EntryValue.t> = "values"
@send external entries: t => Webapi__Iterator.t<(string, EntryValue.t)> = "entries"

Notice that keys(), values(), and entries() are nullary methods, not getters. Exposing record fields like keys: Webapi__Iterator.t<string> is incorrect because those are not the correct types. This type should be reverted back to an abstract type.

Relates to #2

TheSpyder commented 2 years ago

This happened in 2ba24b0a when I added the fetch bindings. They were @send before, not @get, I don’t know what I was thinking.

TheSpyder commented 2 years ago

In theory the record fields could be defined as functions, but in my experience calling a record function always generates a Curry call at runtime. So I agree the type should revert to abstract.

TheSpyder commented 2 years ago

Released as 0.5.0