-
Notifications
You must be signed in to change notification settings - Fork 464
deprecate unsafe host-specific bindings from stdlib #7334
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
Conversation
e15a2b4
to
53d89a4
Compare
runtime/Stdlib.res
Outdated
@val external globalThis: {..} = "globalThis" | ||
@deprecated("Use rescript-webapi instead") @val external window: Dom.window = "window" | ||
@deprecated("Use rescript-webapi instead") @val external document: Dom.document = "document" | ||
@deprecated("Use rescript-webapi instead") @val external globalThis: {..} = "globalThis" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globalThis
is not host-specific but is actually part of the ECMAScript spec: https://tc39.es/ecma262/multipage/global-object.html#sec-globalthis
So maybe the deprecation warning should say Use Js.globalThis
instead of recommending rescript-webapi
? (a Js.globalThis binding already exists)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, actually globalThis
was added by me 😅
It is intentional that it points to the {..}
type. Depending on the environment, it can be a Node.js global
, DedicatedWorkerGlobalScope
, etc.
Others are pretty much host-specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I should keep globalThis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. It's part of the JS standard and useful when dealing with global variables or classes.
Here's a case: https://forum.rescript-lang.org/t/is-it-good-idea-having-binding-to-js-this/2922
But it should not be used too often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
53d89a4
to
8951931
Compare
Fixes rescript-lang/rescript-core#240