From e2299f2f3d08edb47f6731636240b2b316f85b01 Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Mon, 11 Mar 2024 18:40:12 +0530 Subject: [PATCH 1/2] add TS support for `useIsSupportedTaxonomy` hook --- hooks/use-is-supported-taxonomy/{index.js => index.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename hooks/use-is-supported-taxonomy/{index.js => index.ts} (82%) diff --git a/hooks/use-is-supported-taxonomy/index.js b/hooks/use-is-supported-taxonomy/index.ts similarity index 82% rename from hooks/use-is-supported-taxonomy/index.js rename to hooks/use-is-supported-taxonomy/index.ts index c954909d..0e4a3b26 100644 --- a/hooks/use-is-supported-taxonomy/index.js +++ b/hooks/use-is-supported-taxonomy/index.ts @@ -1,7 +1,7 @@ import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; -export const useIsSupportedTaxonomy = (postType, taxonomyName) => { +export const useIsSupportedTaxonomy = (postType: string, taxonomyName: string) => { return useSelect( (select) => { const postTypeObject = select(coreStore).getPostType(postType); @@ -16,5 +16,5 @@ export const useIsSupportedTaxonomy = (postType, taxonomyName) => { return [!!isSupportedTaxonomy, hasResolvedPostType]; }, [postType, taxonomyName], - ); + ) as [boolean, boolean]; }; From c6293bfd4118341b4664e57adeee6f337b142ea4 Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Tue, 12 Mar 2024 10:30:35 +0530 Subject: [PATCH 2/2] improve return value --- hooks/use-is-supported-taxonomy/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/use-is-supported-taxonomy/index.ts b/hooks/use-is-supported-taxonomy/index.ts index 0e4a3b26..2a9ca0e6 100644 --- a/hooks/use-is-supported-taxonomy/index.ts +++ b/hooks/use-is-supported-taxonomy/index.ts @@ -16,5 +16,5 @@ export const useIsSupportedTaxonomy = (postType: string, taxonomyName: string) = return [!!isSupportedTaxonomy, hasResolvedPostType]; }, [postType, taxonomyName], - ) as [boolean, boolean]; + ) as [isSupportedTaxonomy: boolean, hasResolvedPostType: boolean]; };