From dfc0cda1e5b68e951cf3b3768cfaced9bf5254ec Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Sun, 28 May 2023 14:59:33 +0200 Subject: [PATCH] Improve type checking of propType validators --- src/shared/propTypes.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/shared/propTypes.ts b/src/shared/propTypes.ts index f0026dbe..8ff43a6d 100644 --- a/src/shared/propTypes.ts +++ b/src/shared/propTypes.ts @@ -1,4 +1,10 @@ -export function isMinDate(props: Record, propName: string, componentName: string) { +import type { Validator } from 'prop-types'; + +export const isMinDate: Validator = function isMinDate( + props, + propName, + componentName, +) { const { [propName]: minDate } = props; if (!minDate) { @@ -20,9 +26,13 @@ export function isMinDate(props: Record, propName: string, comp } return null; -} +}; -export function isMaxDate(props: Record, propName: string, componentName: string) { +export const isMaxDate: Validator = function isMaxDate( + props, + propName, + componentName, +) { const { [propName]: maxDate } = props; if (!maxDate) { @@ -44,4 +54,4 @@ export function isMaxDate(props: Record, propName: string, comp } return null; -} +};