diff --git a/test/parse.test.js b/test/parse.test.js index a8dc739a7..9f2dedf2d 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -89,11 +89,14 @@ describe('Parse', () => { expect(ds.millisecond()).toEqual(ms.millisecond()) }) - it('String Other, Null and isValid', () => { + it('String Other, Undefined and Null and isValid', () => { global.console.warn = jest.genMockFunction()// moment.js otherString will throw warn expect(dayjs('otherString').toString().toLowerCase()).toBe(moment('otherString').toString().toLowerCase()) + expect(dayjs(undefined).toDate()).toEqual(moment(undefined).toDate()) expect(dayjs().isValid()).toBe(true) + expect(dayjs(undefined).isValid()).toBe(true) expect(dayjs('').isValid()).toBe(false) + expect(dayjs(null).isValid()).toBe(false) expect(dayjs('otherString').isValid()).toBe(false) expect(dayjs(null).toString().toLowerCase()).toBe(moment(null).toString().toLowerCase()) }) diff --git a/types/index.d.ts b/types/index.d.ts index 0b9a47622..313f95752 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -10,7 +10,7 @@ declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, loca declare namespace dayjs { interface ConfigTypeMap { - default: string | number | Date | Dayjs + default: string | number | Date | Dayjs | null | undefined } export type ConfigType = ConfigTypeMap[keyof ConfigTypeMap]