diff --git a/test/index.d.test.ts b/test/index.d.test.ts index 6a2f2eb2b..47ec60b5e 100644 --- a/test/index.d.test.ts +++ b/test/index.d.test.ts @@ -71,3 +71,9 @@ dayjs().isSame(dayjs()) dayjs().isAfter(dayjs()) dayjs('2000-01-01').isLeapYear() + +dayjs.extend((o, c, d) => { + o.locale.trim() + new c().unix() // eslint-disable-line new-cap + d().unix() +}) diff --git a/types/index.d.ts b/types/index.d.ts index b568b5656..cec7a4be8 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,9 +1,9 @@ export = dayjs; -declare function dayjs (config?: dayjs.ConfigType, option?: dayjs.OptionType): dayjs.Dayjs +declare function dayjs (date?: dayjs.DateType, option?: dayjs.OptionType): dayjs.Dayjs declare namespace dayjs { - export type ConfigType = string | number | Date | Dayjs + export type DateType = string | number | Date | Dayjs export type OptionType = { locale: string } @@ -20,7 +20,7 @@ declare namespace dayjs { } class Dayjs { - constructor (config?: ConfigType) + constructor (date?: DateType) clone(): Dayjs @@ -54,7 +54,7 @@ declare namespace dayjs { format(template?: string): string - diff(dayjs: Dayjs, unit: UnitType, float?: boolean): number + diff(date: DateType, unit: UnitType, float?: boolean): number valueOf(): number @@ -74,22 +74,22 @@ declare namespace dayjs { toString(): string - isBefore(dayjs: Dayjs): boolean + isBefore(date: DateType): boolean - isSame(dayjs: Dayjs): boolean + isSame(date: DateType): boolean - isAfter(dayjs: Dayjs): boolean + isAfter(date: DateType): boolean isLeapYear(): boolean locale(arg1: any, arg2?: any): Dayjs } - export type PluginFunc = (option: ConfigType, d1: Dayjs, d2: Dayjs) => void + export type PluginFunc = (option: any, c: typeof Dayjs, d: typeof dayjs) => void - export function extend(plugin: PluginFunc, option?: ConfigType): Dayjs + export function extend(plugin: PluginFunc, option?: any): Dayjs - export function locale(arg1: any, arg2?: any): string + export function locale(preset: string | { name: string, [key: string]: any }, object?: { [key: string]: any }, isLocal?: boolean): string export function isDayjs(d: any): d is Dayjs }