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
I want to add a generic to the ContextVariableMap and change the inner type based on the called route like so:
declare module "hono"{interfaceContextVariableMap{context: Context<unknown>;}}app.get("/app/foo",(c)=>{constctx=c.get("context")asContext<BrowserAppModuleRequest>;console.log(`Got request from ${ctx.payload["shop-id"]}`);returnc.html('<h1>Hello World</h1>',);});
Is there any better solution than using as to change the type to the expected type? I think I need some kind of route level overload of the ContextVariableMap 🤔
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
-
Hey,
I want to add a generic to the ContextVariableMap and change the inner type based on the called route like so:
Is there any better solution than using
as
to change the type to the expected type? I think I need some kind of route level overload of the ContextVariableMap 🤔Beta Was this translation helpful? Give feedback.
All reactions