payload
payload copied to clipboard
fix(plugin-form-builder): resolve labelValue from LabelFunction
Description
The type definitions from @payloadcms/plugin-form-builder are not being included in the final bundle, causing the following error when trying to get the default export from the package.
import FormBuilder from '@payloadcms/plugin-form-builder';
// => TS7016: Could not find a declaration file for module @payloadcms/plugin-form-builder.
My initial asumption was that the error was preventing the types from being generated, which is the original reason for this PR. However, the type-generation step might also be missing in the build workflow.
This change adapts only the relevant part from getTranslation to handle the case where the label variable is of type LabelFunction.
Maybe it would be more ideal to use the getTranslation function directly. Not sure if this is an option, though I think I've seen it being used in other client components.
- [x] I have read and understand the CONTRIBUTING.md document in this repository.
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
Checklist:
- [x] Existing test suite passes locally with my changes
On another note, I had to run pnpm build:types within the packages/plugin-form-builder project to get them into the dist. Does this run on prePublish?
This step does not seem necessary for other packages like plugin-nested-docs, which get the types built from the pnpm run build:all command in the root.