Skip to content

Consider adding useful extension module #5

Open
@nojaf

Description

@nojaf

While the aspiration of this project is to have bindings for anything available in the browser, it might be interesting consider having an additional auxiliary module.

Or to phrase it differently: some API methods are shit. Like https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement. You pass it any string and get an element back. Maybe you want to create something more specific and get a better type back like document.createElement("input") and get HTMLInputElement back.

So having something like:

type document

type htmlInputElement

@scope("document")
external createInputElement: (unit, @as("input") _) => htmlInputElement =
  "createElement"

let i = createInputElement()

The input string can't be misspelled and the return type is better.
Perhaps each current API module can have an APIExt companion module?
Let me know what you thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions