Use generics for VercelRequest and VercelResponse in @vercel/node #6402
Unanswered
mattrossman
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In
express
, theRequest
andResponse
types use generics which lets you annotate the types forreq.body
and the arg forres.json()
on an endpoint handler.For example, I can write a JSDoc comment like this:
And now I get hints on
req.body
telling me which fields it contains along with their types and descriptions. Similary I get autocomplete on the argument tores.json()
. I assume this applies for Typescript users as well.Currently, the
VercelRequest
andVercelResponse
just use theany
type here, so you don't get any autocomplete or type hints. I think it would be helpful to follow a similar usage of generics so that devs can be explicit about the input/output of their serverless functions.Beta Was this translation helpful? Give feedback.
All reactions