Skip to content

Unsafe host-specific bindings #240

Closed
rescript-lang/rescript
#7334

Description

@cometkim

We have this in the Core module.

@val external window: Dom.window = "window"
@val external document: Dom.document = "document"
@val external globalThis: {..} = "globalThis"

(ref: https://github.com/rescript-association/rescript-core/blob/22642ea/src/RescriptCore.res#L47-L49)

However, using window and document is not safe because

I also think that the compiler and the Core should not promote specific hosts. window & document are part of the HTML and has nothing to do with Node.js. global is Node.js specific and has nothing to do with browsers.

IMO Core should delegate bindings to third-parties (e.g. rescript-webapi) and keep the representation in JavaScript itself.

Activity

  1. tsnobip commented on Mar 7, 2025

    @tsnobip
    Member

    I agree with you, we should likely deprecate it in Core and remove it from stdlib.

  2. added 4 commits that reference this issue on Mar 12, 2025
    09e5408
    4fc7a83
    e15a2b4
    53d89a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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