payloadcms / payloadcms/payload
If two 'blocks' fields reference the same block definition, only one of the fields will reference the interfaceName of the block in the generated types.
Open
@GermanJablo is already working on this.
Since Mar 10, 2026.
area: core
Bug
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
If you add two 'blocks' fields to the same collection that reference the same blocks, only one of them will properly reference the interface name in the generated payload-types.ts.
For example, with this definition for Users:
import type { Block, CollectionConfig } from 'payload'
export const SampleBlock: Block = {
slug: 'sample-block',
interfaceName: 'SampleBlock',
fields: [
{
name: 'field',
type: 'text',
},
],
}
export const Users: CollectionConfig = {
slug: 'users',
admin: {
useAsTitle: 'email',
},
auth: true,
fields: [
// Email added by default
// Add more fields as needed
{
name: 'field1',
type: 'blocks',
blocks: [SampleBlock],
},
{
name: 'field2',
type: 'blocks',
blocks: [SampleBlock],
},
],
}
... the generated type is:
export interface User {
id: number;
field1?:
| {
field?: string | null;
id?: string | null;
blockName?: string | null;
blockType: 'sample-block';
}[]
| null;
field2?: SampleBlock[] | null;
[snip]
... but it should be:
export interface User {
id: number;
field1?: SampleBlock[] | null;
field2?: SampleBlock[] | null;
[snip]
It looks to me that only the last field gets assigned the proper interface type?
Link to the code that reproduces this issue
https://github.com/galenwarren/payloadcms-bug-demo
Reproduction Steps
Run npm run generate:types and see what is generated for User.
Which area(s) are affected?
area: core
Environment Info
Binaries: Node: 24.6.0 npm: 11.5.1 Yarn: N/A pnpm: N/A Relevant Packages: payload: 3.79.0 next: 15.4.11 @payloadcms/db-sqlite: 3.79.0 @payloadcms/drizzle: 3.79.0 @payloadcms/graphql: 3.79.0 @payloadcms/next/utilities: 3.79.0 @payloadcms/richtext-lexical: 3.79.0 @payloadcms/translations: 3.79.0 @payloadcms/ui/shared: 3.79.0 react: 19.2.1 react-dom: 19.2.1 Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC PMX 6.17.4-2 (2025-12-19T07:49Z) Available memory (MB): 16384 Available CPU cores: 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.