Skip to content

Include more JS primitives for Untagged variants #7147

Closed as not planned
Closed as not planned

Description

@nojaf

I'm trying to model blobParts of https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob#blobparts for the new WebAPI bindings.

@unboxed
type blobPart =
  | String(string)
  | Blob(blob)
  | ArrayBuffer(ArrayBuffer.t)
  | TypedArray(TypedArray.t<int>)

However, I cannot use ArrayBuffer.t and TypedArray.t in combination with the @unboxed.
Could some of these be extended?

Activity

  1. nojaf commented on Nov 13, 2024

    @nojaf
    CollaboratorAuthor

    I'm hitting the limitations of @unboxed again for https://github.com/rescript-lang/experimental-rescript-webapi/pull/7/files#r1839785692

    Modelling https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle

    It should be something like

    @unboxed
    type fillStyle =
      | String(string)
      | Gradient(canvasGradient)
      | Pattern(canvasPattern)

    It would be great if I can input some sort of check for the unboxed via attribute, something like:

    | @check("$0 instanceof CanvasGradient") Gradient(canvasGradient) // where $0 is the object in place.

  2. cometkim commented on Mar 18, 2025

    @cometkim
    Member

    Blob is a part of Web API (File API spec), not a JS primitive.

    It is actually an outer class and has more complex semantics at the prototype level than JS primitives. Handling this safely will add tons of complexity to the compiler.

    As we discussed before (rescript-lang/rescript-core#240), I think it's not a good long-term direction for the compiler to add specializations for specific environments, because it bloats the compiler code, reduces configurability, and limits future enhancements.

    If it cannot be extended in a generalized way, it should be kept to a minimum as possible.

  3. github-actions commented on May 1, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  4. added
    stale
    on May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stale

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions