How to Type a Middleware factory?
Lemme first show you what I want, so you can get the gist of it. (Consider me less experienced in typescript)
This is what I put together. This almost works
I get autocompletion in vscode, but when I press tab and proceed with the autocompletion, I get an error that looks like this (the screenshot attached). Feels like i'm in the right path but cant exactly make a solid type out it.
Now, for my very specific use case, i did make an workaround by making that
T
generic partial
But this feels like a half measure. And provided that different validation libs might affect the type of input in subtle ways, I need to know how to properly type this thing.
Thank you
1 Reply
please expand this thread panel horizontally. easier to read without the code getting wrapped
Well, ctx doesnt get typed in this way, look at this code
I think I'm supposed to use
t.middleware
, this way I do get the context/meta types, but i cant seem to make a custom factory. Modifying above code like this throws an error
MiddlewareBuilder is not assignable ..
such and such