@@ -304,7 +304,7 @@ function instrumentPrototype<T extends NewableFunction>(target: T): void {
304
304
305
305
while ( current && current !== Object . prototype ) {
306
306
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' ) {
308
308
methodNames . add ( name ) ;
309
309
}
310
310
} ) ;
@@ -313,20 +313,24 @@ function instrumentPrototype<T extends NewableFunction>(target: T): void {
313
313
314
314
// Instrument each method on the prototype
315
315
methodNames . forEach ( methodName => {
316
- const originalMethod = proto [ methodName ] ;
316
+ const originalMethod = ( proto as Record < string , unknown > ) [ methodName ] ;
317
317
318
318
if ( ! originalMethod || isInstrumented ( originalMethod ) ) {
319
319
return ;
320
320
}
321
321
322
322
// 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__ ;
326
330
327
331
if ( ! instanceOptions ) {
328
332
// 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 ) ;
330
334
}
331
335
332
336
// Use the existing wrapper but with instance-specific context/options
@@ -342,7 +346,7 @@ function instrumentPrototype<T extends NewableFunction>(target: T): void {
342
346
true , // noMark = true since we'll mark the prototype method
343
347
) ;
344
348
345
- return wrapper . apply ( this , args ) ;
349
+ return ( wrapper as ( ... args : any [ ] ) => any ) . apply ( this , args ) ;
346
350
} ;
347
351
348
352
markAsInstrumented ( wrappedMethod ) ;
0 commit comments