Skip to content

Unsafe host-specific bindings #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cometkim opened this issue Jul 26, 2024 · 1 comment · Fixed by rescript-lang/rescript#7334
Closed

Unsafe host-specific bindings #240

cometkim opened this issue Jul 26, 2024 · 1 comment · Fixed by rescript-lang/rescript#7334

Comments

@cometkim
Copy link
Member

cometkim commented Jul 26, 2024

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.

@tsnobip
Copy link
Member

tsnobip commented Mar 7, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants