Skip to content

Commit f75b001

Browse files
committed
Fix typescript errors.
1 parent d0e199a commit f75b001

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Date/DatePickerInput.shared.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type DatePickerInputProps = {
1212
withDateFormatInLabel?: boolean
1313
hideValidationErrors?: boolean
1414
hasError?: boolean
15-
onValidationError?: ((error: string) => void) | undefined
15+
onValidationError?: ((error: string | null) => void) | undefined
1616
calendarIcon?: string
1717
saveLabel?: string
1818
} & Omit<

src/Date/inputUtils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function useDateInput({
1616
value: Date | undefined
1717
validRange: ValidRangeType | undefined
1818
inputMode: 'start' | 'end'
19-
onValidationError?: ((error: string) => void) | undefined
19+
onValidationError?: ((error: string | null) => void) | undefined
2020
}) {
2121
const { isDisabled, isWithinValidRange, validStart, validEnd } =
2222
useRangeChecker(validRange)
@@ -43,7 +43,7 @@ export default function useDateInput({
4343
() => 'notAccordingToDateFormat'
4444
)(inputFormat)
4545
setError(inputError)
46-
onValidationError(inputError)
46+
onValidationError && onValidationError(inputError)
4747
return
4848
}
4949

@@ -55,7 +55,7 @@ export default function useDateInput({
5555
if (isDisabled(finalDate)) {
5656
const inputError = getTranslation(locale, 'dateIsDisabled')
5757
setError(inputError)
58-
onValidationError(inputError)
58+
onValidationError && onValidationError(inputError)
5959
return
6060
}
6161
if (!isWithinValidRange(finalDate)) {
@@ -86,12 +86,12 @@ export default function useDateInput({
8686
]
8787
const inputError = errors.filter((n) => n).join(' ')
8888
setError(errors.filter((n) => n).join(' '))
89-
onValidationError(inputError)
89+
onValidationError && onValidationError(inputError)
9090
return
9191
}
9292

9393
setError(null)
94-
onValidationError(null)
94+
onValidationError && onValidationError(null)
9595
if (inputMode === 'end') {
9696
onChange(finalDate)
9797
} else {

0 commit comments

Comments
 (0)