Skip to content

Commit 38c02a4

Browse files
committed
Improve type checking of propType validators
1 parent 38fe9e1 commit 38c02a4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/shared/propTypes.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
export function isMinDate(props: Record<string, unknown>, propName: string, componentName: string) {
1+
import type { Validator } from 'prop-types';
2+
3+
export const isMinDate: Validator<Date | null | undefined> = function isMinDate(
4+
props,
5+
propName,
6+
componentName,
7+
) {
28
const { [propName]: minDate } = props;
39

410
if (!minDate) {
@@ -20,9 +26,13 @@ export function isMinDate(props: Record<string, unknown>, propName: string, comp
2026
}
2127

2228
return null;
23-
}
29+
};
2430

25-
export function isMaxDate(props: Record<string, unknown>, propName: string, componentName: string) {
31+
export const isMaxDate: Validator<Date | null | undefined> = function isMaxDate(
32+
props,
33+
propName,
34+
componentName,
35+
) {
2636
const { [propName]: maxDate } = props;
2737

2838
if (!maxDate) {
@@ -44,4 +54,4 @@ export function isMaxDate(props: Record<string, unknown>, propName: string, comp
4454
}
4555

4656
return null;
47-
}
57+
};

0 commit comments

Comments
 (0)