-
Notifications
You must be signed in to change notification settings - Fork 216
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
Remove Node.js and DOM type references from core-common #7720
base: master
Are you sure you want to change the base?
Conversation
This pull request is now in conflicts. Could you fix it @paulius-valiunas? 🙏 |
@mergify queue |
🟠 Waiting for conditions to match
|
This pull request is now in conflicts. Could you fix it @paulius-valiunas? 🙏 |
@tcobbs-bentley could you help with the failing Android build? I don't have the environment for that and I'm not sure what could be causing it... maybe just setting breakpoints at the lines I changed would show that some of the expected globals are undefined? |
I will investigate. If it's something trivial, I'll probably push changes to this PR. |
When running in Android I get a run-time exception:
I'll see if adding a declare const like for self and window fixes the problem. |
@@ -44,7 +47,7 @@ export class RpcRegistry { | |||
|
|||
public static get instance() { | |||
if (!RpcRegistry._instance) { | |||
const globalObj: any = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}; | |||
const globalObj: any = global ?? self ?? window ?? {}; |
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.
This is the line that is throwing an exception in Android. Updating it to be the following fixes the problem in Android, but I believe that you need to revert all of your changes that abandoned the old typeof
checks, because the new code is fundamentally different (and definitely broken for global
in Android, and probably broken for self
and window
):
const globalObj: any = (typeof global !== "undefined" ? global : undefined) ?? self ?? window ?? {};
What I mean by that is that both self
and window
are defined in Android, but if they weren't, then my updated line above would not work, while the original code would. Adding the following doesn't do any good, because declare const
just lets the TypeScript compiler know that a variable is supposed to exist; it does not actually create the variable:
declare const global: any;
Because of this, you may need to remove the declare const
statements that you added (in addition to switching back to the old typeof x !== "undefined"
checks with ternary operators).
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.
If you really don't like the old code, you could instead do something like this:
private static get anyGlobal(): any {
return typeof global !== "undefined" ? global : undefined;
}
...
const globalObj: any = RpcRegistry.anyGlobal ?? self ?? window ?? {};
Do the same for anySelf
and anyWindow
.
No description provided.