@@ -10,6 +10,7 @@ import {
1010 response ,
1111} from "./request-utils"
1212import { buildJsonLog , buildTextLog } from "./utils"
13+ import { AddContextFn } from "./types"
1314
1415export type FlytrapLogsOptions = {
1516 /**
@@ -129,41 +130,66 @@ export function createFlytrapLogger<T>({
129130 getContext,
130131 addContext,
131132 flush,
132- catchUncaughtAction < T extends ( ...args : unknown [ ] ) => Promise < unknown > > (
133+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134+ catchUncaughtAction < T extends ( ...args : any [ ] ) => Promise < any > > (
133135 fn : T ,
134136 options ?: Partial < z . infer < typeof baseLogSchema > >
135137 ) {
136- // @ts -expect-error: `addContext` is incompatible due to `T`
137- return catchUncaughtAction ( fn , addContext , flush , options )
138+ return catchUncaughtAction (
139+ fn ,
140+ addContext as AddContextFn < z . infer < typeof baseLogSchema > > ,
141+ flush ,
142+ options
143+ )
138144 } ,
139145 // Request utils
140- catchUncaughtRoute < T extends { params : Record < string , unknown > } > (
141- fn : ( request : Request , context : T ) => Promise < Response > | Response ,
146+ catchUncaughtRoute <
147+ RequestType extends Request ,
148+ T extends { params : Record < string , unknown > } ,
149+ > (
150+ fn : ( request : RequestType , context : T ) => Promise < Response > | Response ,
142151 options ?: Partial < z . infer < typeof baseLogSchema > >
143152 ) {
144- // @ts -expect-error: `addContext` is incompatible due to `T`
145- return catchUncaughtRoute ( fn , addContext , flush , options )
153+ return catchUncaughtRoute (
154+ fn ,
155+ addContext as AddContextFn < z . infer < typeof baseLogSchema > > ,
156+ flush ,
157+ options
158+ )
146159 } ,
147160 parseJson ( request : Request ) {
148- // @ts -expect-error: `addContext` is incompatible due to `T`
149- return parseJson ( request , addContext )
161+ return parseJson (
162+ request ,
163+ addContext as AddContextFn < z . infer < typeof baseLogSchema > >
164+ )
150165 } ,
151166 parseText ( request : Request ) {
152- // @ts -expect-error: `addContext` is incompatible due to `T`
153- return parseText ( request , addContext )
167+ return parseText (
168+ request ,
169+ addContext as AddContextFn < z . infer < typeof baseLogSchema > >
170+ )
154171 } ,
155172 // Response utils
156173 response ( body : BodyInit , opts : ResponseInit = { } ) {
157- // @ts -expect-error: `addContext` is incompatible due to `T`
158- return response ( body , opts , addContext )
174+ return response (
175+ body ,
176+ opts ,
177+ addContext as AddContextFn < z . infer < typeof baseLogSchema > >
178+ )
159179 } ,
160180 json ( data : unknown , opts : ResponseInit = { } ) {
161- // @ts -expect-error: `addContext` is incompatible due to `T`
162- return json ( data , opts , addContext )
181+ return json (
182+ data ,
183+ opts ,
184+ addContext as AddContextFn < z . infer < typeof baseLogSchema > >
185+ )
163186 } ,
164187 redirect ( url : string | URL , status ?: number ) {
165- // @ts -expect-error: `addContext` is incompatible due to `T`
166- return redirect ( url , status , addContext )
188+ return redirect (
189+ url ,
190+ status ,
191+ addContext as AddContextFn < z . infer < typeof baseLogSchema > >
192+ )
167193 } ,
168194 }
169195}
0 commit comments