payload
payload copied to clipboard
plugin-form-builder: Type error when adding fields to existing blocks
I am encountering a type error whenever I am trying to extend existing blocks.
import { fields } from '@payloadcms/plugin-form-builder';
formBuilder({
fields: {
select: {
...fields.select,
fields: [
...fields.select.fields,
{
name: 'hasMultiple',
label: 'Has Multiple',
type: 'checkbox',
defaultValue: false,
},
],
},
},
}),
This is the error I am getting:
Property 'fields' does not exist on type 'Block | ((fieldConfig?: boolean | FieldConfig) => Block)'. Property 'fields' does not exist on type '(fieldConfig?: boolean | FieldConfig) => Block'.ts(2339)
it will work if you do a casting of the field as Block (fields.select as Block)
select: {
...fields.select,
fields: [
...(fields.select as Block).fields,
{
name: 'hasMultiple',
label: 'Has Multiple',
type: 'checkbox',
defaultValue: false,
},
],
},
This plugin is now being maintained in the Packages Directory of the Payload Monorepo. This repo will soon be archived and all open issues be closed. This issue, however, will be transferred over. Please refer to this open discussion for more details.