typescript intellisense not working for payload type?

default discord avatar
Thinh Nguyen12 months 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
    12 months ago

    what type does it show for the req object?

  • default discord avatar
    Thinh Nguyen12 months ago

    req is showing up as

    any

    ,

  • discord user avatar
    jarrod_not_jared
    12 months ago

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

  • default discord avatar
    Thinh Nguyen12 months ago

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

    Screenshot_2023-07-22_at_3.52.26_PM.png
  • discord user avatar
    jarrod_not_jared
    12 months ago

    And if you go to your user type def?

  • default discord avatar
    Thinh Nguyen12 months 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

    Screenshot_2023-07-22_at_4.46.51_PM.png
  • discord user avatar
    jarrod_not_jared
    12 months ago

    But only in next-payload?

  • default discord avatar
    Thinh Nguyen12 months ago

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

  • discord user avatar
    alessiogr
    12 months 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
    Thinh Nguyen12 months ago

    Thank you @alessiogr, 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 help straight from the Payload team with an Enterprise License.