-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Describe the Bug
I noticed an inconsistency in the typing of the custom property between fields and collections/globals which makes it hard to build well-typed plugins.
For fields, the custom property is nicely typeable via module augmentation:
declare module 'payload' {
export interface FieldCustom {
'plugin-import-export'?: {
// plugin-specific field props...
}
}
}This works because the field config uses the exported FieldCustom type:
| custom?: FieldCustom |
This is what the Import/Export plugin uses, for example.
However, for collection/global configs, the custom property is currently not typeable in the same way. It is defined as:
| custom?: Record<string, any> |
Because of this, plugins that require configuration on the collection/global level via custom cannot provide proper TypeScript types for these options. You lose type safety and auto-completion exactly where plugins often need structured configuration.
Something like the following currently has no effect on the types:
declare module 'payload' {
export interface CollectionCustom {
'plugin-import-export'?: {
// plugin-specific collection props...
}
}
}Link to the code that reproduces this issue
https://github.com/payloadcms/payload
Which area(s) are affected? (Select all that apply)
area: core
Environment Info
Binaries:
Node: 24.3.0
npm: 11.4.2
Yarn: N/A
pnpm: 10.12.4
Relevant Packages:
payload: 3.64.0
next: 15.5.6
@payloadcms/db-mongodb: 3.64.0
@payloadcms/db-sqlite: 3.64.0
@payloadcms/drizzle: 3.64.0
@payloadcms/graphql: 3.64.0
@payloadcms/next/utilities: 3.64.0
@payloadcms/plugin-multi-tenant: 3.64.0
@payloadcms/translations: 3.64.0
@payloadcms/ui/shared: 3.64.0
react: 19.2.0
react-dom: 19.2.0
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041
Available memory (MB): 24576
Available CPU cores: 14