@@ -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
@@ -337,12 +341,12 @@ function instrumentPrototype<T extends NewableFunction>(target: T): void {
337341 spanName : methodName ,
338342 spanOp : 'rpc' ,
339343 } ,
340- originalMethod ,
344+ originalMethod as ( ... args : any [ ] ) => any ,
341345 undefined ,
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 ) ;
0 commit comments