Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

typescript intellisense not working for payload type?

default discord avatar
giaguuns2 years ago
10

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 🙌

  • discord user avatar
    alessiogr
    2 years ago

    what type does it show for the req object?

  • default discord avatar
    giaguuns2 years ago

    req is showing up as

    any

    ,

  • discord user avatar
    jarrod_not_jared
    2 years ago

    Can you go to definition of the Access type? What does it show?

  • default discord avatar
    giaguuns2 years ago

    It appears to be correct according to the docs. TS server is running fine

  • discord user avatar
    jarrod_not_jared
    2 years ago

    And if you go to your user type def?

  • default discord avatar
    giaguuns2 years ago

    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

  • discord user avatar
    jarrod_not_jared
    2 years ago

    But only in next-payload?

  • default discord avatar
    giaguuns2 years ago

    Yes, type completion is working as expected on a regular payload server, but unfortunately not on next-payload

  • discord user avatar
    alessiogr
    2 years ago

    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

  • default discord avatar
    giaguuns2 years ago

    Thank you

    @360823574644129795

    , this definitely fixed it! Actually just having

    @types/express

    is sufficient enough to provide the type completion.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.