Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
When creating custom translations and merging the custom translation keys with the default translation keys, and then pass it to the generic TFunction type, Typescript complains that the function does not satisfy the LabelFunction type in a label field.
The reason for this is that the LabelFunction type is not generic, and it's always using the default TFunction which itself uses the DefaultTranslationKey if no type is passed to it.
This is solved by making the LabelFunction generic and forward the TTranslationKeys to the TFunction type.
When creating custom translations and merging the custom translation keys with the default translation keys, and then pass it to the generic TFunction type, Typescript complains that the function does not satisfy the LabelFunction type in a label field.
The reason for this is that the LabelFunction type is not generic, and it's always using the default TFunction which itself uses the DefaultTranslationKey if no type is passed to it.
This is solved by making the LabelFunction generic and forward the TTranslationKeys to the TFunction type.
Following this documentation: https://payloadcms.com/docs/configuration/i18n#typescript
Example: