Description
The new typedefs break any code that was relying on the generics the old DefinitelyTyped defs used to handle typing the attributes passed to edit and save.
I'm currently putting together a PR that ports over generics for the registration functions.
Step-by-step reproduction instructions
Try to build the following:
registerBlockType(blockJson as unknown as BlockConfiguration<{ allowedBlocks?: string[], templateLock?: EditorTemplateLock }>, {
icon: contents,
edit({attributes: {allowedBlocks, templateLock}, clientId, isSelected}) {
return <>
<InsertSiblingOrChildBlockShortcut clientId={clientId} targetBlockName="plaudit-accordion-block/accordion" addedBlockName="plaudit-accordion-block/item" isSelected={isSelected} />
<div
{...useInnerBlocksProps(useBlockProps(), {
allowedBlocks,
template: [['core/paragraph', {}]],
templateLock,
})}
/>
</>;
},
save() {
return <div {...useInnerBlocksProps.save(useBlockProps.save())} />;
}
});
Previously, allowedBlocks and templateLock would have been properly typed as string[]|undefined and EditorTemplateLock|undefined respectively. This is no longer the case because the registerBlockType function is missing the generic that links up the types.
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
The new typedefs break any code that was relying on the generics the old DefinitelyTyped defs used to handle typing the attributes passed to edit and save.
I'm currently putting together a PR that ports over generics for the registration functions.
Step-by-step reproduction instructions
Try to build the following:
Previously,
allowedBlocksandtemplateLockwould have been properly typed asstring[]|undefinedandEditorTemplateLock|undefinedrespectively. This is no longer the case because theregisterBlockTypefunction is missing the generic that links up the types.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.