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.
We have this in the
Coremodule.(ref: https://github.com/rescript-association/rescript-core/blob/22642ea/src/RescriptCore.res#L47-L49)
However, using
windowanddocumentis not safe becauseJs.globalThisobject binding rescript#6909 (comment)globalThis.I also think that the compiler and the Core should not promote specific hosts.
window&documentare part of the HTML and has nothing to do with Node.js.globalis 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.