-
Notifications
You must be signed in to change notification settings - Fork 465
RescriptReactRouter crash on master (window
vs. $$window
)
#6905
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
RescriptReactRouter crash on master (window
vs. $$window
)
#6905
Comments
The undocumented extension |
Ok it will be a And the existing So it could be let window = typeof globalThis.window === "undefined" ? undefined : globalThis.window;
// and it could be better
let window = globalThis.window; // treat as an option |
I could fix the builtin but I think it's better to deprecate (at least rename it) it in the end. Just having https://forum.rescript-lang.org/t/is-it-good-idea-having-binding-to-js-this/2922 |
Umm... found a counterexample from test.
|
@scope("globalThis")
external window: option<Dom.window> = "window"
@scope("globalThis")
external history: option<Dom.history> = "history" |
Yep. so I'm now trying to split it into |
Maybe we should better get rid of this undocumented feature altogether and replace it by bindings or There does not seem to be too much usage across the ecosystem: https://github.com/search?q=%22%25external%22+language%3Arescript&type=code |
That's something to decide. I can agree that it's a convenient sugar syntax to have. It's also good to have for compatibility reasons. The reason it is not used not much is because the API has not been officially introduced. We can get rid of it, or make it more sensible and introduce as an officially supported feature. |
On current master,
RescriptReactRouter.useUrl()
crashes.The actual crash is in the first line of
RescriptReactRouter.hash()
:The error I get in the browser is
On the ReScript side we have
AFAIK
%external
is used to guard the access ofwindow
withtypeof
so that the code won't crash if run on a platform that doesn't havewindow
.Before #6831 the first line of the JS output was
so the problem did not occur.
/cc @cometkim @cristianoc
The text was updated successfully, but these errors were encountered: