Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LabelFunction type error when merging custom keys #9335

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marwinhormiz
Copy link

@marwinhormiz marwinhormiz commented Nov 19, 2024

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:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant