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
fix(utils): Remove WINDOW
from utils
#6024
fix(utils): Remove WINDOW
from utils
#6024
Conversation
*/ | ||
export const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window; | ||
// eslint-disable-next-line deprecation/deprecation | ||
const WINDOW = getGlobalObject<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.
I think this still causes issues right? Since Window
is at the top level.
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 don't think the user reported issue has anything to do with top-level Window
usage since the error directly references browser.d.ts
:
node_modules/@sentry/utils/types/browser.d.ts:4:69 - error TS2304: Cannot find name 'Window'.
In master
there is Window
in browser.d.ts
:
export declare const WINDOW: InternalGlobal & Window;
export declare function htmlTreeAsString(elem: unknown, keyAttrs?: string[]): string;
export declare function getLocationHref(): string;
export declare function getDomElement<E = any>(selector: string): E | null;
After this PR changes, browser.d.ts
no longer has this:
export declare function htmlTreeAsString(elem: unknown, keyAttrs?: string[]): string;
export declare function getLocationHref(): string;
export declare function getDomElement<E = any>(selector: string): E | null;
And in the outputted JavaScript there are no generics or types so Window
is gone too:
// eslint-disable-next-line deprecation/deprecation
const WINDOW = getGlobalObject();
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.
Ah of course, it's not exported!
Fixes #6016
This issue is caused by the fact that
Window
ends up in the utils type definitions.This PR:
WINDOW
from utilsWINDOW
to:@sentry/browser
where it is exported for use elsewhere@sentry/tracing/browser
- Can be removed once tracing is split into browser/node codeOffline
andReportingObserver
integrations since they don't have any dependencies other than utilswindow
since they're not used outside the browserWINDOW
from@sentry/browser
or@sentry/react