Ask questionsApplication state in Routers not typed properly
While using typescript and defining a state for the application like so:
const app = new Application<AppState>()
typings for ctx.state is not typed accordingly to AppState interface with this code
new Router().get('/', (ctx) => ctx.state)
Am I missing something or do the Router class need generic typings similar to Application?
While running the code the state is actually there, only the typings that are incorrect.
Answer questions kitsonk
@Tsourdox yeah, it is an oversight. I am doing a rewrite of the router right now that will include the ability to assert the state as a generic.
Currently though you should be able to do something like this:
new Router().get('/', (ctx: RouterContext<RouteParams, AppState>) => ctx.state);
Related questionsNo questions were found.