I started with the
next-payload
repo and once I got to creating access control functions, I noticed that I kept getting
any
types despite providing one in the generic.
Am I missing something from my
tsconfig,json
file? Also using generated types which are 🙌
what type does it show for the req object?
req is showing up as
any
,
Can you go to definition of the Access type? What does it show?
It appears to be correct according to the docs. TS server is running fine
And if you go to your user type def?
this is my generated type from running
payload generate:types
I was able to reproduce the same issue with a fresh installation of nextjs and next-payload
But only in next-payload?
Yes, type completion is working as expected on a regular payload server, but unfortunately not on next-payload
I've been having the exact same error where req is any on my project - but for PayloadHandler (used in collection endpoints).
I managed to fix it by installing express and @types/express. No idea why that fixed it or why that caused it though
Thank you @alessiogr, this definitely fixed it! Actually just having
@types/express
is sufficient enough to provide the type completion.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.