TS Typing for Blocks

default discord avatar
Redblueflame
4 weeks ago
5

Hi!


First of all, thanks a lot for the amazing work! Currently in the process of evaluating PayloadCMS as a Prismic replacement, due to self-hosting needs.


One question I had was with the typescript typings generation for blocks.


I have the same blocks present within multiple Field across collections, and while in the GraphQL output, the Blocks are typed with an explicit notation, it is not the case for the typescript ones, that instead inlines all the possibilities.


Is there a reason for that, or just an oversight?



Thanks in advance for your help!



Small bump ^^


I have a workaround that is based on creating the types myself, but it is not the most optimal workflow

  • discord user avatar
    denolfe
    Payload Team
    4 weeks ago

    As of now, the type generation looks at each collection one at a time and types it all the way through, with the exception of relationships. We've heard feedback regarding the block typing being inline instead of shared across all usages. This is definitely something that we could improve in the future - not currently in our roadmap, though.



    Feel free to submit a feature request, so we can discuss/prioritize with everyone.



    https://github.com/payloadcms/payload/discussions
  • default discord avatar
    Redblueflame
    4 weeks ago

    Thanks!


    Will do when I have some time ^^



    Done, it's available here ^^


    https://github.com/payloadcms/payload/discussions/2617
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.