DEV Community

Kacper Zawojski
Kacper Zawojski

Posted on

Payload v4: every block gets its own TypeScript interface (hashed on collision)

A nice quality-of-life change in Payload v4's type generation.

Previously, a block only got its own TypeScript interface if you set interfaceName. In v4 the name is derived automatically from the slug (PascalCased), and when two different blocks would collide on a name, the second one gets a stable suffix from a content hash — so types never silently overwrite each other:

// slug 'content-block'  -> interface ContentBlock
// a colliding block of a different shape -> Hero_3F2A1B0C  (deterministic hash)
Enter fullscreen mode Exit fullscreen mode

The key word is deterministic: the hash is derived from the block's shape, so regenerating payload-types.ts doesn't churn your diffs. No more "why did half my types get renamed" after a codegen run.

Top comments (0)