TS Typing for Blocks

default discord avatar
7 months ago


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
    Payload Team
    7 months 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.

  • default discord avatar
    7 months ago


    Will do when I have some time ^^

    Done, it's available here ^^

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

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