From 8355a2200f3d156be56e3d260b4da83a5c70087a Mon Sep 17 00:00:00 2001 From: Derek Sifford Date: Thu, 11 Jul 2019 18:50:41 -0400 Subject: [PATCH] [@wordpress/blocks] miscellaneous fixes for compatibility with wordpress core (#36827) * [@wordpress/blocks] miscellaneous fixes for compatibility with wordpress core * fix lint errors --- types/wordpress__blocks/api/categories.d.ts | 4 ++- types/wordpress__blocks/api/factory.d.ts | 11 +++----- types/wordpress__blocks/api/registration.d.ts | 2 +- types/wordpress__blocks/api/serializer.d.ts | 6 ++--- types/wordpress__blocks/api/templates.d.ts | 2 +- .../block-content-provider.d.ts | 27 +++++++++++++++++-- types/wordpress__blocks/index.d.ts | 4 +-- .../wordpress__blocks-tests.tsx | 2 +- 8 files changed, 40 insertions(+), 18 deletions(-) diff --git a/types/wordpress__blocks/api/categories.d.ts b/types/wordpress__blocks/api/categories.d.ts index 14a04f6ed5..28ccf7b65d 100644 --- a/types/wordpress__blocks/api/categories.d.ts +++ b/types/wordpress__blocks/api/categories.d.ts @@ -1,7 +1,9 @@ +import { Dashicon } from '@wordpress/components'; + export interface Category { slug: string; title: string; - icon: JSX.Element | null; + icon?: JSX.Element | Dashicon.Icon | null; } /** diff --git a/types/wordpress__blocks/api/factory.d.ts b/types/wordpress__blocks/api/factory.d.ts index 0f20e60db8..c0715b586d 100644 --- a/types/wordpress__blocks/api/factory.d.ts +++ b/types/wordpress__blocks/api/factory.d.ts @@ -11,7 +11,7 @@ import { Block, BlockInstance, Transform } from '../'; export function cloneBlock>( block: BlockInstance, mergeAttributes?: Partial, - newInnerBlocks?: readonly BlockInstance[] + newInnerBlocks?: BlockInstance[] ): BlockInstance; /** @@ -24,7 +24,7 @@ export function cloneBlock>( export function createBlock>( name: string, attributes?: Partial, - innerBlocks?: readonly BlockInstance[] + innerBlocks?: BlockInstance[] ): BlockInstance; /** @@ -66,7 +66,7 @@ export function getBlockTransforms = Record>>; +export function getPossibleBlockTransformations(blocks: BlockInstance[]): Array>>; /** * Switch one or more blocks into one or more blocks of the new block type. @@ -74,7 +74,4 @@ export function getPossibleBlockTransformations(blocks: readonly BlockInstance[] * @param blocks - One or more `BlockInstance`. * @param name - Block name of block to be switched to. */ -export function switchToBlockType( - blocks: BlockInstance | readonly BlockInstance[], - name: string -): BlockInstance[] | null; +export function switchToBlockType(blocks: BlockInstance | BlockInstance[], name: string): BlockInstance[] | null; diff --git a/types/wordpress__blocks/api/registration.d.ts b/types/wordpress__blocks/api/registration.d.ts index beb93d16ba..b9d387401e 100644 --- a/types/wordpress__blocks/api/registration.d.ts +++ b/types/wordpress__blocks/api/registration.d.ts @@ -25,7 +25,7 @@ export function getBlockType(name: string | undefined): Block | unde /** * Returns all registered blocks. */ -export function getBlockTypes(): ReadonlyArray>; +export function getBlockTypes(): Array>; /** * Returns an array with the child blocks of a given block. diff --git a/types/wordpress__blocks/api/serializer.d.ts b/types/wordpress__blocks/api/serializer.d.ts index 3309585e38..4c834059cc 100644 --- a/types/wordpress__blocks/api/serializer.d.ts +++ b/types/wordpress__blocks/api/serializer.d.ts @@ -28,7 +28,7 @@ export function getBlockMenuDefaultClassName(blockName: string): string; export function getSaveContent( blockTypeOrName: Block | string, attributes: T, - innerBlocks?: readonly BlockInstance[] + innerBlocks?: BlockInstance[] ): string; /** @@ -42,7 +42,7 @@ export function getSaveContent( export function getSaveElement( blockTypeOrName: Block | string, attributes: T, - innerBlocks?: readonly BlockInstance[] + innerBlocks?: BlockInstance[] ): ReactChild; /** @@ -50,4 +50,4 @@ export function getSaveElement( * * @param blocks - Block(s) to serialize. */ -export function serialize(blocks: readonly BlockInstance[]): string; +export function serialize(blocks: BlockInstance[]): string; diff --git a/types/wordpress__blocks/api/templates.d.ts b/types/wordpress__blocks/api/templates.d.ts index 8ae01af85f..4e5baf254e 100644 --- a/types/wordpress__blocks/api/templates.d.ts +++ b/types/wordpress__blocks/api/templates.d.ts @@ -9,7 +9,7 @@ export interface TemplateArray extends ReadonlyArray