Conversation
| @@ -0,0 +1,57 @@ | |||
| // Generated by ReScript, PLEASE EDIT WITH CARE | |||
|
|
|||
| import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js"; | |||
There was a problem hiding this comment.
This is why I added @rescript/runtime to the dependencies.
I think it is correct to do so.
There was a problem hiding this comment.
Would making @rescript/runtime a peer dependency work?
There was a problem hiding this comment.
I'm not sure, the reason I want to be explicit with "@rescript/runtime" is that I see this popping up in isolated installs.
| "sources": [{ "dir": "src", "subdirs": true }], | ||
| "package-specs": [{ "module": "commonjs", "in-source": true }], | ||
| "suffix": ".bs.js", | ||
| "bs-dev-dependencies": [], |
| let safeMakeEvent = eventName => | ||
| if Js.typeof(event) == "function" { | ||
| if typeof(event) == #function { | ||
| makeEventIE11Compatible(eventName) |
There was a problem hiding this comment.
I hope we no longer care about IE11?
|
I would also make @rescript/runtime a peer dependency. |
| @@ -52,16 +52,16 @@ module FormData = { | |||
|
|
|||
| let getFile = (formData, name) => { | |||
| switch formData->getUnsafe(name) { | |||
| | Some(value) => Js.typeof(value) === "string" ? None : Some(value->_asFile) | |||
| | Some(value) => typeof(value) === #string ? None : Some(value->_asFile) | |||
| | _ => None | |||
| } | |||
| } | |||
|
|
|||
| let getAll = (t, string) => { | |||
| t | |||
| ->getAllUnsafe(string) | |||
| ->Js.Array2.map(value => { | |||
| Js.typeof(value) === "string" ? String(value) : File(value->_asFile) | |||
| ->Array.map(value => { | |||
| typeof(value) === #string ? String(value) : File(value->_asFile) | |||
| }) | |||
| } | |||
There was a problem hiding this comment.
why don't you use untagged variants here?
module FormData = {
type t
@unboxed
type formValue =
| String(string)
| File(Js.File.t)
@new external make: unit => t = "FormData"
@send external append: (t, string, ~filename: string=?) => unit = "append"
@send external delete: (t, string) => unit = "delete"
@return(nullable) @send external get: (t, string) => option<formValue> = "get"
@send external getAll: (t, string) => array<formValue> = "getAll"
let getString = (formData, name) => {
switch formData->get(name) {
| Some(String(value)) => Some(value)
| _ => None
}
}
let getFile = (formData, name) => {
switch formData->get(name) {
| Some(File(value)) => Some(value)
| _ => None
}
}
@send external set: (string, string) => unit = "set"
@send external has: string => bool = "has"
// @send external keys: t => Iterator.t<string> = "keys";
// @send external values: t => Iterator.t<value> = "values";
}There was a problem hiding this comment.
Because I do not care about the existing code. At lot of it can be improved, this is not what this PR is about.
|
Any update on this? |
|
No, I might even close this. |
|
I don't have the bandwidth right now, feel free to take inspiration of this PR to create a new one. |
I would like to start creating some alphas of a v12+ world