Skip to content

Commit

Permalink
Fix wrong argument types
Browse files Browse the repository at this point in the history
  • Loading branch information
ypresto committed Nov 29, 2018
1 parent 183bf8e commit 963fd2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions test/index.d.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
22 changes: 11 additions & 11 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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 }

Expand All @@ -20,7 +20,7 @@ declare namespace dayjs {
}

class Dayjs {
constructor (config?: ConfigType)
constructor (date?: DateType)

clone(): Dayjs

Expand Down Expand Up @@ -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

Expand All @@ -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
locale(preset: string | { name: string, [key: string]: any }, object?: { [key: string]: 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
}

0 comments on commit 963fd2a

Please sign in to comment.