mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #45656 fix(@wordpress/blocks): add element type to normalized icon by @emilio-martinez
Icon declaration in registerBlockType should also allow for a plain React Element, as noted in the documentation. See https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional.
This commit is contained in:
parent
b42ab79e27
commit
25e743aea3
4
types/wordpress__blocks/index.d.ts
vendored
4
types/wordpress__blocks/index.d.ts
vendored
@ -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;
|
||||
|
||||
@ -311,6 +311,18 @@ blocks.registerBlockType('my/foo', {
|
||||
category: 'common',
|
||||
});
|
||||
|
||||
// $ExpectType Block<{}> | undefined
|
||||
blocks.registerBlockType('my/foo', {
|
||||
attributes: {},
|
||||
icon: (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path fill="none" d="M0 0h24v24H0V0z" />
|
||||
</svg>
|
||||
),
|
||||
title: 'Foo',
|
||||
category: 'common',
|
||||
});
|
||||
|
||||
// $ExpectType Block<{ foo: string; }> | undefined
|
||||
blocks.registerBlockType<{ foo: string }>('my/foo', {
|
||||
attributes: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user