From abab1715a83abac2b386a00c087e948908b4a255 Mon Sep 17 00:00:00 2001 From: louis <1891109+dotlouis@users.noreply.github.com> Date: Sat, 2 Feb 2019 05:18:21 +0100 Subject: [PATCH] chore: Added shorthand units to UnitType (#470) --- index.d.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index 1ef70ca57..024d47151 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,7 +7,11 @@ declare namespace dayjs { export type OptionType = { locale: string } - export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'date' + type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms' + export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'quarter' | 'year' | 'date' | UnitTypeShort; + + type OpUnitTypeShort = 'w' + export type OpUnitType = UnitType | "week" | OpUnitTypeShort; interface DayjsObject { years: number @@ -44,17 +48,17 @@ declare namespace dayjs { set(unit: UnitType, value: number): Dayjs - add(value: number, unit: UnitType): Dayjs + add(value: number, unit: OpUnitType): Dayjs - subtract(value: number, unit: UnitType): Dayjs + subtract(value: number, unit: OpUnitType): Dayjs - startOf(unit: UnitType): Dayjs + startOf(unit: OpUnitType): Dayjs - endOf(unit: UnitType): Dayjs + endOf(unit: OpUnitType): Dayjs format(template?: string): string - diff(dayjs: Dayjs, unit: UnitType, float?: boolean): number + diff(dayjs: Dayjs, unit: OpUnitType, float?: boolean): number valueOf(): number @@ -74,11 +78,11 @@ declare namespace dayjs { toString(): string - isBefore(dayjs: Dayjs, unit?: UnitType): boolean + isBefore(dayjs: Dayjs, unit?: OpUnitType): boolean - isSame(dayjs: Dayjs, unit?: UnitType): boolean + isSame(dayjs: Dayjs, unit?: OpUnitType): boolean - isAfter(dayjs: Dayjs, unit?: UnitType): boolean + isAfter(dayjs: Dayjs, unit?: OpUnitType): boolean isLeapYear(): boolean