You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument of type 'Queue<Properties>' is not assignable to parameter of type 'NextApiHandler<any>'.
Type 'Queue<Properties>' provides no match for the signature '(req: NextApiRequest, res: NextApiResponse<any>): void | Promise<void>'.ts(2345)
Input Code
Discovered when doing a Sentry integration
Expected behavior/code
I didn't expect a typescript error, as quirrel/next should be returning an interface that extends NextApiHandler. Since we don't want to make a hard dependency on next, we can just provide sufficient type overlap.
Possible Solution
/*Conversion of type 'Queue<Properties>' to type 'NextApiHandler<any>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'Queue<Properties>' provides no match for the signature '(req: NextApiRequest, res: NextApiResponse<any>): void | Promise<void>'*/
Since Queue<Payload> is unique per integration, my suggestion would be to use a union type to add the Quirrel properties. (I'm pretty mediocre at complex types, so this is my best approximation)
I was able to verify this typing by putting the following code in locally:
typeQuirrelNextHandler=(req: any,res: any)=>void|Promise<void>;typeQueueFixed<Payload=any>=QuirrelNextHandler&Queue<Payload>;exportconstMyQueueName: QueueFixed=Queue<Properties>("api/queues/<redacted>",async(job)=>{// ...});// <= must enqueue off this objectexportdefaultwithSentry(MyQueueName);// <= route handling
edit Unfortunately, any other next-style wrappers will also lose access to the queue object. I've updated the workaround code to reflect what I needed to do to get sentry integration working
The text was updated successfully, but these errors were encountered:
Bug Report
Current Behavior
Input Code
Discovered when doing a Sentry integration
Expected behavior/code
I didn't expect a typescript error, as quirrel/next should be returning an interface that extends NextApiHandler. Since we don't want to make a hard dependency on next, we can just provide sufficient type overlap.
Possible Solution
Since
Queue<Payload>
is unique per integration, my suggestion would be to use a union type to add the Quirrel properties. (I'm pretty mediocre at complex types, so this is my best approximation)@https://github.com/quirrel-dev/quirrel/blob/main/src/next.ts#L35
I was able to verify this typing by putting the following code in locally:
edit Unfortunately, any other next-style wrappers will also lose access to the queue object. I've updated the workaround code to reflect what I needed to do to get sentry integration working
The text was updated successfully, but these errors were encountered: