Skip to content

Commit

Permalink
change export type
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/index.d.ts
  • Loading branch information
Ben Grynhaus committed Feb 18, 2019
1 parent 279e2fe commit 2cde4d7
Showing 1 changed file with 61 additions and 55 deletions.
116 changes: 61 additions & 55 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,100 +1,106 @@
declare const dayjs: dayjs;
export = dayjs;

declare const dayjs: dayjs
export default dayjs
declare namespace dayjs {
type ConfigType = string | number | Date | Dayjs

export type ConfigType = string | number | Date | Dayjs
type OptionType = { locale: string }

export type OptionType = { locale: string }
type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
type UnitTypeSingular = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'date' | UnitTypeShort;
type UnitTypePlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years' | 'dates'
type UnitType = UnitTypeSingular | UnitTypePlural

export type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
export type UnitTypeSingular = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'date' | UnitTypeShort;
export type UnitTypePlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years' | 'dates'
export type UnitType = UnitTypeSingular | UnitTypePlural
type OpUnitTypeShort = 'w'
type OpUnitType = UnitType | "week" | OpUnitTypeShort;

export type OpUnitTypeShort = 'w'
export type OpUnitType = UnitType | "week" | OpUnitTypeShort;

export type PluginFunc<TPlugin> = (option: ConfigType, d1: Dayjs, d2: Dayjs) => void

export interface dayjs<TPlugin = {}> {
(config?: ConfigType, option?: OptionType): {} extends TPlugin ? Dayjs : Dayjs & TPlugin
type PluginFunc<TPlugin> = (option: ConfigType, d1: Dayjs, d2: Dayjs) => void
}

extend<UPlugin extends object>(plugin: PluginFunc<UPlugin>, option?: ConfigType): dayjs<TPlugin & UPlugin>
locale(arg1: any, arg2?: any): string
isDayjs(d: any): d is Dayjs
unix(t: number): Dayjs
interface dayjs<TPlugin = {}> {
(config?: dayjs.ConfigType, option?: dayjs.OptionType): {} extends TPlugin
? Dayjs
: Dayjs & TPlugin;

extend<UPlugin extends object>(
plugin: dayjs.PluginFunc<UPlugin>,
option?: dayjs.ConfigType
): dayjs<TPlugin & UPlugin>;
locale(arg1: any, arg2?: any): string;
isDayjs(d: any): d is Dayjs;
unix(t: number): Dayjs;
}

export interface DayjsObject {
years: number
months: number
date: number
hours: number
minutes: number
seconds: number
milliseconds: number
declare interface DayjsObject {
years: number;
months: number;
date: number;
hours: number;
minutes: number;
seconds: number;
milliseconds: number;
}

export class Dayjs {
constructor(config?: ConfigType)
declare class Dayjs {
constructor(config?: dayjs.ConfigType);

clone(): Dayjs
clone(): Dayjs;

isValid(): boolean
isValid(): boolean;

year(): number
year(): number;

month(): number
month(): number;

date(): number
date(): number;

day(): number
day(): number;

hour(): number
hour(): number;

minute(): number
minute(): number;

second(): number
second(): number;

millisecond(): number
millisecond(): number;

set(unit: UnitType, value: number): Dayjs
set(unit: dayjs.UnitType, value: number): Dayjs;

add(value: number, unit: OpUnitType): Dayjs
add(value: number, unit: dayjs.OpUnitType): Dayjs;

subtract(value: number, unit: OpUnitType): Dayjs
subtract(value: number, unit: dayjs.OpUnitType): Dayjs;

startOf(unit: OpUnitType): Dayjs
startOf(unit: dayjs.OpUnitType): Dayjs;

endOf(unit: OpUnitType): Dayjs
endOf(unit: dayjs.OpUnitType): Dayjs;

format(template?: string): string
format(template?: string): string;

diff(dayjs: ConfigType, unit: OpUnitType, float?: boolean): number

valueOf(): number
valueOf(): number;

unix(): number
unix(): number;

daysInMonth(): number
daysInMonth(): number;

toDate(): Date
toDate(): Date;

toArray(): number[]
toArray(): number[];

toJSON(): string
toJSON(): string;

toISOString(): string
toISOString(): string;

toObject(): DayjsObject
toObject(): DayjsObject;

toString(): string
toString(): string;

isBefore(dayjs: ConfigType, unit?: OpUnitType): boolean

isSame(dayjs: ConfigType, unit?: OpUnitType): boolean

isAfter(dayjs: ConfigType, unit?: OpUnitType): boolean

locale(arg1: any, arg2?: any): Dayjs
locale(arg1: any, arg2?: any): Dayjs;
}

0 comments on commit 2cde4d7

Please sign in to comment.