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
We've just upgraded from 1.1.26 to 1.2.10 today and we're having some problems with type inference from the guard. This was working yesterday in one of our plugins
exportconstjobContext=(config: ContextConfig)=>newElysia().guard({body: jobCloudEventSchema,}).resolve({as: 'scoped'},async({ headers, body })=>{return{ctx: awaitcreateJobContext(config,headers,body.data),}}).onError({as: 'scoped'},async({ code, error, ctx })=>{constjsonError=serializeError(error)if(!ctx){constlogger=ConsoleLogger()awaitlogger.error('jobContext not found',jsonError)returndapr.drop}const{ logger, status }=ctxawaitlogger.error(`Unhandled error: (${code})`,jsonError)awaitstatus('error-processing',JSON.stringify(jsonError))returndapr.drop})
But now, type inference is lost on resolve > body. I've read the docs on guard but I'm confused with scoping. It mentions that you can add scoping on guard like:
.guard({as: 'scoped',body: jobCloudEventSchema,})
but I'm not sure its doing anything, and type inference is still lost.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We've just upgraded from
1.1.26
to1.2.10
today and we're having some problems with type inference from the guard. This was working yesterday in one of our pluginsBut now, type inference is lost on
resolve > body
. I've read the docs on guard but I'm confused with scoping. It mentions that you can add scoping on guard like:but I'm not sure its doing anything, and type inference is still lost.
Actually I can do this:
So I don't think guard scoping is defined anyway.
Any advice on using guards in plugins?
Beta Was this translation helpful? Give feedback.
All reactions