From eda01c392efc76dba5e2f6e9ef205ddb857c3cef Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 16 Oct 2026 15:28:25 +0530 Subject: [PATCH 01/14] Block Editor: Convert InserterListbox to TypeScript --- .../{context.js => context.ts} | 2 +- .../inserter-listbox/{group.jsx => group.tsx} | 6 ++- .../inserter-listbox/{index.jsx => index.tsx} | 11 ++++- .../inserter-listbox/{item.jsx => item.tsx} | 15 +++++-- .../src/components/inserter-listbox/row.jsx | 8 ---- .../src/components/inserter-listbox/row.tsx | 20 +++++++++ .../src/components/inserter-listbox/types.ts | 42 +++++++++++++++++++ 7 files changed, 89 insertions(+), 15 deletions(-) rename packages/block-editor/src/components/inserter-listbox/{context.js => context.ts} (69%) rename packages/block-editor/src/components/inserter-listbox/{group.jsx => group.tsx} (80%) rename packages/block-editor/src/components/inserter-listbox/{index.jsx => index.tsx} (67%) rename packages/block-editor/src/components/inserter-listbox/{item.jsx => item.tsx} (72%) delete mode 100644 packages/block-editor/src/components/inserter-listbox/row.jsx create mode 100644 packages/block-editor/src/components/inserter-listbox/row.tsx create mode 100644 packages/block-editor/src/components/inserter-listbox/types.ts diff --git a/packages/block-editor/src/components/inserter-listbox/context.js b/packages/block-editor/src/components/inserter-listbox/context.ts similarity index 69% rename from packages/block-editor/src/components/inserter-listbox/context.js rename to packages/block-editor/src/components/inserter-listbox/context.ts index ff002c3f82c9a6..c6245756682503 100644 --- a/packages/block-editor/src/components/inserter-listbox/context.js +++ b/packages/block-editor/src/components/inserter-listbox/context.ts @@ -1,6 +1,6 @@ import { createContext } from '@wordpress/element'; -const InserterListboxContext = createContext(); +const InserterListboxContext = createContext< unknown >( undefined ); InserterListboxContext.displayName = 'InserterListboxContext'; export default InserterListboxContext; diff --git a/packages/block-editor/src/components/inserter-listbox/group.jsx b/packages/block-editor/src/components/inserter-listbox/group.tsx similarity index 80% rename from packages/block-editor/src/components/inserter-listbox/group.jsx rename to packages/block-editor/src/components/inserter-listbox/group.tsx index 2667b728f2a34c..21a47d3c4a1c50 100644 --- a/packages/block-editor/src/components/inserter-listbox/group.jsx +++ b/packages/block-editor/src/components/inserter-listbox/group.tsx @@ -1,8 +1,12 @@ import { forwardRef, useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { speak } from '@wordpress/a11y'; +import type { ComponentPropsWithoutRef, ForwardedRef } from 'react'; -function InserterListboxGroup( props, ref ) { +function InserterListboxGroup( + props: ComponentPropsWithoutRef< 'div' >, + ref: ForwardedRef< HTMLDivElement > +) { const [ shouldSpeak, setShouldSpeak ] = useState( false ); useEffect( () => { diff --git a/packages/block-editor/src/components/inserter-listbox/index.jsx b/packages/block-editor/src/components/inserter-listbox/index.tsx similarity index 67% rename from packages/block-editor/src/components/inserter-listbox/index.jsx rename to packages/block-editor/src/components/inserter-listbox/index.tsx index 4bea262d81d11a..c1555dc925066d 100644 --- a/packages/block-editor/src/components/inserter-listbox/index.jsx +++ b/packages/block-editor/src/components/inserter-listbox/index.tsx @@ -3,12 +3,19 @@ import { Fragment } from '@wordpress/element'; export { default as InserterListboxGroup } from './group'; export { default as InserterListboxRow } from './row'; export { default as InserterListboxItem } from './item'; +import type { + InserterListBoxWrapperProps, + InserterListboxProps, +} from './types'; -function InserterListBoxWrapper( { key, children } ) { +function InserterListBoxWrapper( { + key, + children, +}: InserterListBoxWrapperProps ) { return { children }; } -function InserterListbox( { children } ) { +function InserterListbox( { children }: InserterListboxProps ) { return ( ) { return ( )[ + 'data-active-item' + ] + ? 0 + : -1, }; if ( Component ) { return ( diff --git a/packages/block-editor/src/components/inserter-listbox/row.jsx b/packages/block-editor/src/components/inserter-listbox/row.jsx deleted file mode 100644 index 05911e11c10255..00000000000000 --- a/packages/block-editor/src/components/inserter-listbox/row.jsx +++ /dev/null @@ -1,8 +0,0 @@ -import { forwardRef } from '@wordpress/element'; -import { Composite } from '@wordpress/components'; - -function InserterListboxRow( props, ref ) { - return ; -} - -export default forwardRef( InserterListboxRow ); diff --git a/packages/block-editor/src/components/inserter-listbox/row.tsx b/packages/block-editor/src/components/inserter-listbox/row.tsx new file mode 100644 index 00000000000000..b8ac634ac9e0b0 --- /dev/null +++ b/packages/block-editor/src/components/inserter-listbox/row.tsx @@ -0,0 +1,20 @@ +import { forwardRef } from '@wordpress/element'; +import { Composite } from '@wordpress/components'; +import type { + ForwardedRef, + ForwardRefExoticComponent, + RefAttributes, +} from 'react'; +import type { InserterListboxRowProps } from './types'; + +function InserterListboxRow( + props: InserterListboxRowProps, + ref: ForwardedRef< HTMLDivElement > +) { + return ; +} + +// Names the props type so the emitted declaration stays portable. +export default forwardRef( InserterListboxRow ) as ForwardRefExoticComponent< + InserterListboxRowProps & RefAttributes< HTMLDivElement > +>; diff --git a/packages/block-editor/src/components/inserter-listbox/types.ts b/packages/block-editor/src/components/inserter-listbox/types.ts new file mode 100644 index 00000000000000..9569ff67aff10a --- /dev/null +++ b/packages/block-editor/src/components/inserter-listbox/types.ts @@ -0,0 +1,42 @@ +import type { + ComponentProps, + ComponentPropsWithoutRef, + ElementType, + ReactNode, +} from 'react'; +import type { Composite } from '@wordpress/components'; + +/** + * Props of `InserterListbox`. + */ +export interface InserterListboxProps { + children?: ReactNode; +} + +/** + * Props of an inserter listbox item, rendered as a button unless `as` is set. + */ +export type InserterListboxItemProps = Omit< + ComponentProps< typeof Composite.Item >, + 'children' | 'render' +> & { + isFirst?: boolean; + as?: ElementType; + children?: + ReactNode | ( ( props: Record< string, unknown > ) => ReactNode ); +}; + +/** + * Props of the fragment the listbox composite renders as. + */ +export interface InserterListBoxWrapperProps { + key?: string; + children?: ReactNode; +} + +/** + * Props of an inserter listbox row. + */ +export type InserterListboxRowProps = ComponentPropsWithoutRef< + typeof Composite.Group +>; From 5383d0fbde3bd89f4917f9077f0e71dea6faf413 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 16 Oct 2026 15:28:32 +0530 Subject: [PATCH 02/14] Block Editor: Convert BlockPatternsPaging to TypeScript --- .../block-patterns-paging/{index.jsx => index.tsx} | 11 +++++++---- .../src/components/block-patterns-paging/types.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) rename packages/block-editor/src/components/block-patterns-paging/{index.jsx => index.tsx} (90%) create mode 100644 packages/block-editor/src/components/block-patterns-paging/types.ts diff --git a/packages/block-editor/src/components/block-patterns-paging/index.jsx b/packages/block-editor/src/components/block-patterns-paging/index.tsx similarity index 90% rename from packages/block-editor/src/components/block-patterns-paging/index.jsx rename to packages/block-editor/src/components/block-patterns-paging/index.tsx index d2bd1473fd2b80..5e0272319f4487 100644 --- a/packages/block-editor/src/components/block-patterns-paging/index.jsx +++ b/packages/block-editor/src/components/block-patterns-paging/index.tsx @@ -5,20 +5,22 @@ import { Button, } from '@wordpress/components'; import { __, _x, _n, sprintf } from '@wordpress/i18n'; +import type { PaginationProps } from './types'; export default function Pagination( { currentPage, numPages, changePage, totalItems, -} ) { +}: PaginationProps ) { return ( { sprintf( // translators: %s: Total number of patterns. _n( '%s item', '%s items', totalItems ), - totalItems + // `sprintf` formats numbers with `%s`. + totalItems as unknown as string ) } { numPages > 1 && ( @@ -60,8 +62,9 @@ export default function Pagination( { { sprintf( // translators: 1: Current page number. 2: Total number of pages. _x( '%1$s of %2$s', 'paging' ), - currentPage, - numPages + // `sprintf` formats numbers with `%s`. + currentPage as unknown as string, + numPages as unknown as string ) } void; + totalItems: number; +} From abac85f2c85be88e13193a8435f915909cdf9b29 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 16 Oct 2026 15:28:39 +0530 Subject: [PATCH 03/14] Block Editor: Convert __unstableInserterMenuExtension to TypeScript --- .../src/components/inserter-menu-extension/index.js | 9 --------- .../src/components/inserter-menu-extension/index.ts | 11 +++++++++++ .../src/components/inserter-menu-extension/types.ts | 10 ++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) delete mode 100644 packages/block-editor/src/components/inserter-menu-extension/index.js create mode 100644 packages/block-editor/src/components/inserter-menu-extension/index.ts create mode 100644 packages/block-editor/src/components/inserter-menu-extension/types.ts diff --git a/packages/block-editor/src/components/inserter-menu-extension/index.js b/packages/block-editor/src/components/inserter-menu-extension/index.js deleted file mode 100644 index 98837fa0e01511..00000000000000 --- a/packages/block-editor/src/components/inserter-menu-extension/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { createSlotFill } from '@wordpress/components'; - -const { Fill: __unstableInserterMenuExtension, Slot } = createSlotFill( - '__unstableInserterMenuExtension' -); - -__unstableInserterMenuExtension.Slot = Slot; - -export default __unstableInserterMenuExtension; diff --git a/packages/block-editor/src/components/inserter-menu-extension/index.ts b/packages/block-editor/src/components/inserter-menu-extension/index.ts new file mode 100644 index 00000000000000..8d4492a458cb88 --- /dev/null +++ b/packages/block-editor/src/components/inserter-menu-extension/index.ts @@ -0,0 +1,11 @@ +import { createSlotFill } from '@wordpress/components'; +import type { InserterMenuExtension } from './types'; + +const { Fill: __unstableInserterMenuExtension, Slot } = createSlotFill( + '__unstableInserterMenuExtension' +); + +// The fill carries its slot as a static. +( __unstableInserterMenuExtension as InserterMenuExtension ).Slot = Slot; + +export default __unstableInserterMenuExtension as InserterMenuExtension; diff --git a/packages/block-editor/src/components/inserter-menu-extension/types.ts b/packages/block-editor/src/components/inserter-menu-extension/types.ts new file mode 100644 index 00000000000000..6ec66f24352765 --- /dev/null +++ b/packages/block-editor/src/components/inserter-menu-extension/types.ts @@ -0,0 +1,10 @@ +import type { createSlotFill } from '@wordpress/components'; + +type SlotFill = ReturnType< typeof createSlotFill >; + +/** + * The inserter menu extension fill, which carries its slot as a static. + */ +export type InserterMenuExtension = SlotFill[ 'Fill' ] & { + Slot: SlotFill[ 'Slot' ]; +}; From 4c462f02d0b0b739a686261c53da0d89c7a2cfcb Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 16 Oct 2026 15:28:46 +0530 Subject: [PATCH 04/14] Block Editor: Convert BlockCard to TypeScript --- .../block-card/{index.jsx => index.tsx} | 47 +++++++------ .../src/components/block-card/types.ts | 66 +++++++++++++++++++ 2 files changed, 93 insertions(+), 20 deletions(-) rename packages/block-editor/src/components/block-card/{index.jsx => index.tsx} (71%) create mode 100644 packages/block-editor/src/components/block-card/types.ts diff --git a/packages/block-editor/src/components/block-card/index.jsx b/packages/block-editor/src/components/block-card/index.tsx similarity index 71% rename from packages/block-editor/src/components/block-card/index.jsx rename to packages/block-editor/src/components/block-card/index.tsx index e160c666a2fa92..20ba46a8e844e8 100644 --- a/packages/block-editor/src/components/block-card/index.jsx +++ b/packages/block-editor/src/components/block-card/index.tsx @@ -14,8 +14,12 @@ import { getBlockType } from '@wordpress/blocks'; import { unlock } from '../../lock-unlock'; import { store as blockEditorStore } from '../../store'; import BlockIcon from '../block-icon'; +import type { BlockCardProps, OptionalParentSelectButtonProps } from './types'; -function OptionalParentSelectButton( { children, onClick } ) { +function OptionalParentSelectButton( { + children, + onClick, +}: OptionalParentSelectButtonProps ) { if ( ! onClick ) { return children; } @@ -51,20 +55,20 @@ function OptionalParentSelectButton( { children, onClick } ) { * } * ``` * - * @param {Object} props Component props. - * @param {string} props.title The title of the block. - * @param {string|Object} props.icon The icon of the block. This can be any of [WordPress' Dashicons](https://developer.wordpress.org/resource/dashicons/), or a custom `svg` element. - * @param {string} props.description The description of the block. - * @param {Object} [props.blockType] Deprecated: Object containing block type data. - * @param {string} [props.className] Additional classes to apply to the card. - * @param {string} [props.name] Custom block name to display before the title. - * @param {string} [props.allowParentNavigation] Show a back arrow to the parent block in some situations. - * @param {string} [props.parentClientId] The parent clientId, if this card is for a parent block. - * @param {string} [props.isChild] Whether the block card is for a child block, in which case, indent the block using an arrow. - * @param {string} [props.clientId] Whether the block card is for a child block, in which case, indent the block using an arrow. - * @param {Element} [props.controls] Controls rendered beside the block title. - * @param {Element} [props.children] Children. - * @return {Element} Block card component. + * @param props Component props. + * @param props.title The title of the block. + * @param props.icon The icon of the block. This can be any of [WordPress' Dashicons](https://developer.wordpress.org/resource/dashicons/), or a custom `svg` element. + * @param props.description The description of the block. + * @param props.blockType Deprecated: Object containing block type data. + * @param props.className Additional classes to apply to the card. + * @param props.name Custom block name to display before the title. + * @param props.allowParentNavigation Show a back arrow to the parent block in some situations. + * @param props.parentClientId The parent clientId, if this card is for a parent block. + * @param props.isChild Whether the block card is for a child block, in which case, indent the block using an arrow. + * @param props.clientId Whether the block card is for a child block, in which case, indent the block using an arrow. + * @param props.controls Controls rendered beside the block title. + * @param props.children Children. + * @return Block card component. */ function BlockCard( { title, @@ -79,7 +83,7 @@ function BlockCard( { children, clientId, controls, -} ) { +}: BlockCardProps ) { if ( blockType ) { deprecated( '`blockType` property in `BlockCard component`', { since: '5.7', @@ -97,8 +101,9 @@ function BlockCard( { unlock( select( blockEditorStore ) ); // Find the top-most parent block that participates in List View. - const parents = getBlockParents( clientId, false ); - const foundParentId = parents.find( ( parentId ) => + // Parent navigation is only allowed for a block's card. + const parents = getBlockParents( clientId!, false ); + const foundParentId = parents.find( ( parentId: string ) => shouldRenderBlockListView( parentId ) ); @@ -140,8 +145,9 @@ function BlockCard( { ? sprintf( /* translators: %s: The name of the parent block. */ __( 'Go to "%s" block' ), + // A selected parent block is registered. getBlockType( parentBlockName ) - ?.title + ?.title as string ) : __( 'Go to parent block' ) } @@ -179,7 +185,8 @@ function BlockCard( { { ! parentClientId && ! isChild && !! name?.length && ( - { title } + // A named card has a title. + { title as string } ) } { children } diff --git a/packages/block-editor/src/components/block-card/types.ts b/packages/block-editor/src/components/block-card/types.ts new file mode 100644 index 00000000000000..c10d025c8fa1a1 --- /dev/null +++ b/packages/block-editor/src/components/block-card/types.ts @@ -0,0 +1,66 @@ +import type { ReactNode } from 'react'; +import type { BlockIconProps } from '../block-icon/types'; + +/** + * Props of the button selecting the parent block, rendered only with a click + * handler. + */ +export interface OptionalParentSelectButtonProps { + children?: ReactNode; + onClick?: () => void; +} + +/** + * Props of `BlockCard`. + */ +export interface BlockCardProps { + /** + * The title of the block. + */ + title?: string; + /** + * The icon of the block. + */ + icon?: BlockIconProps[ 'icon' ]; + /** + * The description of the block. + */ + description?: string; + /** + * Deprecated: Object containing block type data. + */ + blockType?: { + title?: string; + icon?: BlockIconProps[ 'icon' ]; + description?: string; + }; + /** + * Additional classes to apply to the card. + */ + className?: string; + /** + * Custom block name to display before the title. + */ + name?: string; + /** + * Show a back arrow to the parent block in some situations. + */ + allowParentNavigation?: boolean; + /** + * The parent clientId, if this card is for a parent block. + */ + parentClientId?: string; + /** + * Whether the block card is for a child block. + */ + isChild?: boolean; + /** + * The client ID of the block. + */ + clientId?: string; + /** + * Controls rendered beside the block title. + */ + controls?: ReactNode; + children?: ReactNode; +} From 3553fbc612a02521fa96899a6ccd4471c10ed5d1 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 16 Oct 2026 15:28:53 +0530 Subject: [PATCH 05/14] Block Editor: Convert BlockVariationTransforms to TypeScript --- .../{index.jsx => index.tsx} | 61 ++++++++++++++----- .../block-variation-transforms/types.ts | 18 ++++++ 2 files changed, 63 insertions(+), 16 deletions(-) rename packages/block-editor/src/components/block-variation-transforms/{index.jsx => index.tsx} (79%) create mode 100644 packages/block-editor/src/components/block-variation-transforms/types.ts diff --git a/packages/block-editor/src/components/block-variation-transforms/index.jsx b/packages/block-editor/src/components/block-variation-transforms/index.tsx similarity index 79% rename from packages/block-editor/src/components/block-variation-transforms/index.jsx rename to packages/block-editor/src/components/block-variation-transforms/index.tsx index ef76c4e122dced..7df52163575309 100644 --- a/packages/block-editor/src/components/block-variation-transforms/index.jsx +++ b/packages/block-editor/src/components/block-variation-transforms/index.tsx @@ -1,4 +1,9 @@ import { store as blocksStore } from '@wordpress/blocks'; +import type { ComponentProps, ReactElement } from 'react'; +import type { + BlockTypeIconDescriptor, + BlockVariation, +} from '@wordpress/blocks'; import { __, sprintf } from '@wordpress/i18n'; import { Button, @@ -12,13 +17,17 @@ import { useMemo } from '@wordpress/element'; import BlockIcon from '../block-icon'; import { store as blockEditorStore } from '../../store'; import { unlock } from '../../lock-unlock'; +import type { + BlockVariationTransformsProps, + VariationsControlProps, +} from './types'; function VariationsButtons( { className, onSelectVariation, selectedValue, variations, -} ) { +}: VariationsControlProps ) { return (
}> @@ -54,7 +63,7 @@ function VariationsDropdown( { onSelectVariation, selectedValue, variations, -} ) { +}: VariationsControlProps ) { return (
@@ -86,11 +95,20 @@ function VariationsDropdown( { { variation.title } - { variation.description && ( - - { variation.description } - - ) } + { + // An empty description renders nothing. + ( variation.description && ( + + { variation.description } + + ) ) as + | ReactElement< + ComponentProps< + typeof Menu.ItemDescription + > + > + | undefined + } ) ) } @@ -105,14 +123,17 @@ function VariationsToggleGroupControl( { onSelectVariation, selectedValue, variations, -} ) { +}: VariationsControlProps ) { return (
void + } > { variations.map( ( variation ) => ( { - const variationIcons = new Set(); + const variationIcons = new Set< unknown >(); if ( ! variations ) { return false; } - variations.forEach( ( variation ) => { + variations.forEach( ( variation: BlockVariation ) => { if ( variation.icon ) { - variationIcons.add( variation.icon?.src || variation.icon ); + variationIcons.add( + // A variation icon is a descriptor or the icon itself. + ( variation.icon as unknown as BlockTypeIconDescriptor ) + ?.src || variation.icon + ); } } ); return variationIcons.size === variations.length; }, [ variations ] ); - const onSelectVariation = ( variationName ) => { + const onSelectVariation = ( variationName: string ) => { updateBlockAttributes( blockClientId, { - ...variations.find( ( { name } ) => name === variationName ) - .attributes, + // The selected variation is one of the listed ones. + ...( variations as BlockVariation[] ).find( + ( { name } ) => name === variationName + )!.attributes, } ); }; diff --git a/packages/block-editor/src/components/block-variation-transforms/types.ts b/packages/block-editor/src/components/block-variation-transforms/types.ts new file mode 100644 index 00000000000000..c7dc67490e0341 --- /dev/null +++ b/packages/block-editor/src/components/block-variation-transforms/types.ts @@ -0,0 +1,18 @@ +import type { BlockVariation } from '@wordpress/blocks'; + +/** + * Props of the controls switching between the transform variations. + */ +export interface VariationsControlProps { + className: string; + onSelectVariation: ( variationName: string ) => void; + selectedValue?: string; + variations: BlockVariation[]; +} + +/** + * Props of `BlockVariationTransforms`. + */ +export interface BlockVariationTransformsProps { + blockClientId: string; +} From b986673c1d0129e9d98b86514bb6d307729ed25d Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 16 Oct 2026 15:28:59 +0530 Subject: [PATCH 06/14] Block Editor: Convert the BlockVariationTransforms tests to TypeScript --- .../test/{index.jsdom.test.jsx => index.jsdom.test.tsx} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename packages/block-editor/src/components/block-variation-transforms/test/{index.jsdom.test.jsx => index.jsdom.test.tsx} (90%) diff --git a/packages/block-editor/src/components/block-variation-transforms/test/index.jsdom.test.jsx b/packages/block-editor/src/components/block-variation-transforms/test/index.jsdom.test.tsx similarity index 90% rename from packages/block-editor/src/components/block-variation-transforms/test/index.jsdom.test.jsx rename to packages/block-editor/src/components/block-variation-transforms/test/index.jsdom.test.tsx index 44f97a61904f4f..81b4390bbe1d8e 100644 --- a/packages/block-editor/src/components/block-variation-transforms/test/index.jsdom.test.jsx +++ b/packages/block-editor/src/components/block-variation-transforms/test/index.jsdom.test.tsx @@ -1,4 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; +import type { Mock } from 'vitest'; import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { useDispatch, useSelect } from '@wordpress/data'; @@ -30,8 +31,8 @@ const variations = [ describe( 'BlockVariationTransforms', () => { beforeEach( () => { updateBlockAttributes.mockReset(); - useDispatch.mockReturnValue( { updateBlockAttributes } ); - useSelect.mockReturnValue( { + ( useDispatch as Mock ).mockReturnValue( { updateBlockAttributes } ); + ( useSelect as Mock ).mockReturnValue( { activeBlockVariation: variations[ 0 ], variations, canEdit: true, @@ -60,7 +61,7 @@ describe( 'BlockVariationTransforms', () => { it( 'reflects a variation that becomes active after the first render', async () => { const user = userEvent.setup(); - useSelect.mockReturnValue( { + ( useSelect as Mock ).mockReturnValue( { activeBlockVariation: undefined, variations, canEdit: true, @@ -79,7 +80,7 @@ describe( 'BlockVariationTransforms', () => { } ); expect( plainVariation ).not.toBeChecked(); - useSelect.mockReturnValue( { + ( useSelect as Mock ).mockReturnValue( { activeBlockVariation: variations[ 0 ], variations, canEdit: true, From e070d678c431567ca47d461ce6a5ab1f56d555c5 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 16 Oct 2026 15:29:05 +0530 Subject: [PATCH 07/14] Block Editor: Convert BlockVariationPicker to TypeScript --- .../{index.jsx => index.tsx} | 18 +++++++++++---- .../block-variation-picker/types.ts | 22 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) rename packages/block-editor/src/components/block-variation-picker/{index.jsx => index.tsx} (77%) create mode 100644 packages/block-editor/src/components/block-variation-picker/types.ts diff --git a/packages/block-editor/src/components/block-variation-picker/index.jsx b/packages/block-editor/src/components/block-variation-picker/index.tsx similarity index 77% rename from packages/block-editor/src/components/block-variation-picker/index.jsx rename to packages/block-editor/src/components/block-variation-picker/index.tsx index 72cb1c6ba26134..8638380e0f91f1 100644 --- a/packages/block-editor/src/components/block-variation-picker/index.jsx +++ b/packages/block-editor/src/components/block-variation-picker/index.tsx @@ -2,6 +2,9 @@ import clsx from 'clsx'; import { __ } from '@wordpress/i18n'; import { Button, Placeholder } from '@wordpress/components'; import { layout } from '@wordpress/icons'; +import type { ComponentProps } from 'react'; +import type { BlockTypeIconDescriptor } from '@wordpress/blocks'; +import type { BlockVariationPickerProps } from './types'; function BlockVariationPicker( { icon = layout, @@ -10,7 +13,7 @@ function BlockVariationPicker( { variations, onSelect, allowSkip, -} ) { +}: BlockVariationPickerProps ) { const classes = clsx( 'block-editor-block-variation-picker', { 'has-many-variations': variations.length > 4, } ); @@ -37,10 +40,17 @@ function BlockVariationPicker( {