Skip to content

Commit

Permalink
fix(useDateFormat): fix params type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Sep 13, 2024
1 parent 7a538e0 commit 5b940b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/react-use/src/use-date-format/format-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const formatDate = (date: Date, formatStr: string, options: FormatDateOpt

export type DateLike = Date | number | string

export function normalizeDate(date: DateLike) {
export function normalizeDate(date: DateLike | null | undefined): Date {
if (date === null) return new Date(Number.NaN) // null is invalid
if (date === undefined) return new Date()
if (date instanceof Date) return new Date(date)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-use/src/use-date-format/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function useDateFormat(
/**
* a date object or a date string
*/
date: DateLike,
date: DateLike | null | undefined,
/**
* format string
*
Expand Down

0 comments on commit 5b940b2

Please sign in to comment.