Skip to content

Commit

Permalink
fix(): Add missing locale type definition (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
allmoviestvshowslistsfilmography28 authored and iamkun committed Dec 9, 2019
1 parent 69f44c9 commit de38103
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ coverage
# build
/locale
/plugin
dayjs.min.js
/dayjs.min.js
/esm
index.d.ts
/index.d.ts

#dev
demo.js
8 changes: 5 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference path="./locale/index.d.ts" />

export = dayjs;
declare function dayjs (date?: dayjs.ConfigType, option?: dayjs.OptionType, locale?: string): dayjs.Dayjs

Expand Down Expand Up @@ -91,18 +93,18 @@ declare namespace dayjs {

locale(): string

locale(preset: string | { name: string, [key: string]: any }, object?: { [key: string]: any }): Dayjs
locale(preset: string | ILocale, object?: Partial<ILocale>): Dayjs
}

export type PluginFunc = (option: any, c: typeof Dayjs, d: typeof dayjs) => void

export function extend(plugin: PluginFunc, option?: any): Dayjs

export function locale(preset: string | { name: string, [key: string]: any }, object?: { [key: string]: any }, isLocal?: boolean): string
export function locale(preset: string | ILocale, object?: Partial<ILocale>, isLocal?: boolean): string

export function isDayjs(d: any): d is Dayjs

export function unix(t: number): Dayjs

const Ls : { [key: string] : { [key: string]: any } }
const Ls : { [key: string] : ILocale }
}
11 changes: 11 additions & 0 deletions types/locale/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference path="./types.d.ts" />

declare module 'dayjs/locale/*' {
namespace locale {
interface Locale extends ILocale {}
}

const locale: locale.Locale

export = locale
}
33 changes: 33 additions & 0 deletions types/locale/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
declare interface ILocale {
name: string
weekdays?: string[]
months?: string[]
weekStart?: number
weekdaysShort?: string[]
monthsShort?: string[]
weekdaysMin?: string[]
ordinal?: (n: number) => number | string
formats: Partial<{
LT: string
LTS: string
L: string
LL: string
LLL: string
LLLL: string
}>
relativeTime: Partial<{
future: string
past: string
s: string
m: string
mm: string
h: string
hh: string
d: string
dd: string
M: string
MM: string
y: string
yy: string
}>
}

0 comments on commit de38103

Please sign in to comment.