diff --git a/types/wordpress__blocks/index.d.ts b/types/wordpress__blocks/index.d.ts index 94fc8df6fb..839300fa94 100644 --- a/types/wordpress__blocks/index.d.ts +++ b/types/wordpress__blocks/index.d.ts @@ -7,7 +7,7 @@ import { Dashicon } from '@wordpress/components'; import { dispatch, select } from '@wordpress/data'; -import { ComponentType } from 'react'; +import { ComponentType, ReactElement } from 'react'; export * from './api'; export { withBlockContentContext } from './block-content-provider'; @@ -29,7 +29,7 @@ export interface BlockIconNormalized { background?: string; foreground?: string; shadowColor?: string; - src: Dashicon.Icon | ComponentType; + src: Dashicon.Icon | ReactElement | ComponentType; } export type BlockIcon = BlockIconNormalized['src'] | BlockIconNormalized; diff --git a/types/wordpress__blocks/wordpress__blocks-tests.tsx b/types/wordpress__blocks/wordpress__blocks-tests.tsx index 3d42abe472..a73de57856 100644 --- a/types/wordpress__blocks/wordpress__blocks-tests.tsx +++ b/types/wordpress__blocks/wordpress__blocks-tests.tsx @@ -311,6 +311,18 @@ blocks.registerBlockType('my/foo', { category: 'common', }); +// $ExpectType Block<{}> | undefined +blocks.registerBlockType('my/foo', { + attributes: {}, + icon: ( + + + + ), + title: 'Foo', + category: 'common', +}); + // $ExpectType Block<{ foo: string; }> | undefined blocks.registerBlockType<{ foo: string }>('my/foo', { attributes: {