Skip to content

Commit 618c11a

Browse files
committed
fix type issues on global object
1 parent 74efffa commit 618c11a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/tracing/src/hubextensions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ function getDefaultSampleContext(): SampleContext {
129129
// we must be in browser-js (or some derivative thereof)
130130
else {
131131
// we use `getGlobalObject()` rather than `window` since service workers also have a `location` property on `self`
132-
const globalObject = getGlobalObject();
132+
const globalObject = getGlobalObject<WindowOrWorkerGlobalScope>();
133133

134134
if ('location' in globalObject) {
135135
// we take a copy of the location object rather than just a reference to it in case there's a navigation or
136136
// redirect in the instant between when the transaction starts and when the sampler is called
137-
defaultSampleContext.location = { ...globalObject.location };
137+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
138+
defaultSampleContext.location = { ...(globalObject as any).location };
138139
}
139140
}
140141

packages/tracing/test/hub.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe('Hub', () => {
140140
search: '?chase=me&please=thankyou',
141141
};
142142

143-
getGlobalObject().location = dogParkLocation as any;
143+
getGlobalObject<Window>().location = dogParkLocation as any;
144144

145145
const tracesSampler = jest.fn();
146146
const hub = new Hub(new BrowserClient({ tracesSampler }));

0 commit comments

Comments
 (0)