From e286e68452d0d1b7b732dfe9d0e6d1b023bd97c2 Mon Sep 17 00:00:00 2001 From: CatsMiaow Date: Tue, 29 Sep 2020 20:18:40 +0900 Subject: [PATCH 1/2] fix: export type of duration plugin --- types/plugin/duration.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/plugin/duration.d.ts b/types/plugin/duration.d.ts index fceb19066..eed9f71ff 100644 --- a/types/plugin/duration.d.ts +++ b/types/plugin/duration.d.ts @@ -1,16 +1,16 @@ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc -export default plugin +export = plugin type DurationInputType = string | number | object type DurationAddType = number | object | Duration -export declare class Duration { +declare class Duration { constructor (input: DurationInputType, unit?: string, locale?: string) clone(): Duration - + humanize(withSuffix?: boolean): string milliseconds(): number @@ -42,7 +42,7 @@ export declare class Duration { get(unit: string): number add(input: DurationAddType, unit? : string): Duration - + subtract(input: DurationAddType, unit? : string): Duration toJSON(): string From 2ee5abb73fb25da692ba4bbb99531fe320d043fb Mon Sep 17 00:00:00 2001 From: CatsMiaow Date: Wed, 30 Sep 2020 04:00:00 +0900 Subject: [PATCH 2/2] refactor: duration plugin types --- types/plugin/duration.d.ts | 65 ++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/types/plugin/duration.d.ts b/types/plugin/duration.d.ts index eed9f71ff..3f6791523 100644 --- a/types/plugin/duration.d.ts +++ b/types/plugin/duration.d.ts @@ -1,58 +1,61 @@ import { PluginFunc } from 'dayjs' declare const plugin: PluginFunc +export as namespace plugin; export = plugin -type DurationInputType = string | number | object -type DurationAddType = number | object | Duration +declare namespace plugin { + type DurationInputType = string | number | object + type DurationAddType = number | object | Duration -declare class Duration { - constructor (input: DurationInputType, unit?: string, locale?: string) + interface Duration { + new (input: DurationInputType, unit?: string, locale?: string): Duration - clone(): Duration + clone(): Duration - humanize(withSuffix?: boolean): string + humanize(withSuffix?: boolean): string - milliseconds(): number - asMilliseconds(): number + milliseconds(): number + asMilliseconds(): number - seconds(): number - asSeconds(): number + seconds(): number + asSeconds(): number - minutes(): number - asMinutes(): number + minutes(): number + asMinutes(): number - hours(): number - asHours(): number + hours(): number + asHours(): number - days(): number - asDays(): number + days(): number + asDays(): number - weeks(): number - asWeeks(): number + weeks(): number + asWeeks(): number - months(): number - asMonths(): number + months(): number + asMonths(): number - years(): number - asYears(): number + years(): number + asYears(): number - as(unit: string): number + as(unit: string): number - get(unit: string): number + get(unit: string): number - add(input: DurationAddType, unit? : string): Duration + add(input: DurationAddType, unit? : string): Duration - subtract(input: DurationAddType, unit? : string): Duration + subtract(input: DurationAddType, unit? : string): Duration - toJSON(): string + toJSON(): string - toISOString(): string + toISOString(): string - locale(locale: string): Duration + locale(locale: string): Duration + } } declare module 'dayjs' { - export function duration(input?: DurationInputType , unit?: string): Duration - export function isDuration(d: any): d is Duration + export function duration(input?: plugin.DurationInputType , unit?: string): plugin.Duration + export function isDuration(d: any): d is plugin.Duration }