diff --git a/packages/hooks/src/useCountDown/index.ts b/packages/hooks/src/useCountDown/index.ts index bcb8866b76..2ed638e4d5 100644 --- a/packages/hooks/src/useCountDown/index.ts +++ b/packages/hooks/src/useCountDown/index.ts @@ -1,7 +1,7 @@ import dayjs from 'dayjs'; import { useEffect, useMemo, useState } from 'react'; import useLatest from '../useLatest'; -import { isNumber } from '../utils/index'; +import { isNumber } from '../utils'; export type TDate = dayjs.ConfigType; diff --git a/packages/hooks/src/utils/__tests__/index.spec.ts b/packages/hooks/src/utils/__tests__/index.spec.ts index fb63fc19f3..5c96cd79c2 100644 --- a/packages/hooks/src/utils/__tests__/index.spec.ts +++ b/packages/hooks/src/utils/__tests__/index.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import { isBoolean, isFunction, isNumber, isObject, isString, isUndef } from '../index'; +import { isBoolean, isFunction, isNumber, isObject, isString, isUndef } from '../'; describe('shared utils methods', () => { test('isBoolean', () => { @@ -21,7 +21,7 @@ describe('shared utils methods', () => { test('isNumber', () => { expect(isNumber(1)).toBe(true); expect(isNumber(Infinity)).toBe(true); - expect(isNumber(NaN)).toBe(true); + expect(isNumber(NaN)).toBe(false); expect(isNumber('str')).toBe(false); expect(isNumber({})).toBe(false); diff --git a/packages/hooks/src/utils/index.ts b/packages/hooks/src/utils/index.ts index 9cc2bcc7d3..0ffea4fade 100644 --- a/packages/hooks/src/utils/index.ts +++ b/packages/hooks/src/utils/index.ts @@ -4,5 +4,6 @@ export const isFunction = (value: unknown): value is (...args: any) => any => typeof value === 'function'; export const isString = (value: unknown): value is string => typeof value === 'string'; export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean'; -export const isNumber = (value: unknown): value is number => typeof value === 'number'; +export const isNumber = (value: unknown): value is number => + typeof value === 'number' && !Number.isNaN(value); export const isUndef = (value: unknown): value is undefined => typeof value === 'undefined';