Skip to content

Commit 119eabd

Browse files
committed
Fix type issues
1 parent e18ab56 commit 119eabd

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

packages/cloudflare/src/durableobject.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function instrumentPrototype<T extends NewableFunction>(target: T): void {
304304

305305
while (current && current !== Object.prototype) {
306306
Object.getOwnPropertyNames(current).forEach(name => {
307-
if (name !== 'constructor' && typeof current[name] === 'function') {
307+
if (name !== 'constructor' && typeof (current as Record<string, unknown>)[name] === 'function') {
308308
methodNames.add(name);
309309
}
310310
});
@@ -313,20 +313,24 @@ function instrumentPrototype<T extends NewableFunction>(target: T): void {
313313

314314
// Instrument each method on the prototype
315315
methodNames.forEach(methodName => {
316-
const originalMethod = proto[methodName];
316+
const originalMethod = (proto as Record<string, unknown>)[methodName];
317317

318318
if (!originalMethod || isInstrumented(originalMethod)) {
319319
return;
320320
}
321321

322322
// Create a wrapper that gets context/options from the instance at runtime
323-
const wrappedMethod = function (this: any, ...args: any[]) {
324-
const instanceContext = this.__SENTRY_CONTEXT__;
325-
const instanceOptions = this.__SENTRY_OPTIONS__;
323+
const wrappedMethod = function (this: any, ...args: any[]): unknown {
324+
const thisWithSentry = this as {
325+
__SENTRY_CONTEXT__: DurableObjectState;
326+
__SENTRY_OPTIONS__: CloudflareOptions;
327+
};
328+
const instanceContext = thisWithSentry.__SENTRY_CONTEXT__;
329+
const instanceOptions = thisWithSentry.__SENTRY_OPTIONS__;
326330

327331
if (!instanceOptions) {
328332
// Fallback to original method if no Sentry data found
329-
return originalMethod.apply(this, args);
333+
return (originalMethod as (...args: any[]) => any).apply(this, args);
330334
}
331335

332336
// Use the existing wrapper but with instance-specific context/options
@@ -342,7 +346,7 @@ function instrumentPrototype<T extends NewableFunction>(target: T): void {
342346
true, // noMark = true since we'll mark the prototype method
343347
);
344348

345-
return wrapper.apply(this, args);
349+
return (wrapper as (...args: any[]) => any).apply(this, args);
346350
};
347351

348352
markAsInstrumented(wrappedMethod);

packages/cloudflare/test/durableobject.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('instrumentDurableObjectWithSentry', () => {
5151
} as any;
5252
const mockEnv = {} as any; // Environment mock
5353
const initCore = vi.spyOn(SentryCore, 'initAndBind');
54-
const getClientSpy = vi.spyOn(SentryCore, 'getClient').mockReturnValue(undefined);
54+
vi.spyOn(SentryCore, 'getClient').mockReturnValue(undefined);
5555
const options = vi
5656
.fn()
5757
.mockReturnValueOnce({

0 commit comments

Comments
 (0)