From de381039c6ac5833f399bf604d51ab18939cbe52 Mon Sep 17 00:00:00 2001
From: JounQin <5992643+manre57@users.noreply.github.com>
Date: Mon, 9 Dec 2019 17:40:18 +0800
Subject: [PATCH] fix(): Add missing locale type definition (#716)
---
.gitignore | 4 ++--
types/index.d.ts | 8 +++++---
types/locale/index.d.ts | 11 +++++++++++
types/locale/types.d.ts | 33 +++++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 5 deletions(-)
create mode 100644 types/locale/index.d.ts
create mode 100644 types/locale/types.d.ts
diff --git a/.gitignore b/.gitignore
index d022dbe..7894e39 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,9 +15,9 @@ coverage
# build
/locale
/plugin
-dayjs.min.js
+/dayjs.min.js
/esm
-index.d.ts
+/index.d.ts
#dev
demo.js
diff --git a/types/index.d.ts b/types/index.d.ts
index ff664da..a0f38c8 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,3 +1,5 @@
+///
+
export = dayjs;
declare function dayjs (date?: dayjs.ConfigType, option?: dayjs.OptionType, locale?: string): dayjs.Dayjs
@@ -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): 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, 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 }
}
diff --git a/types/locale/index.d.ts b/types/locale/index.d.ts
new file mode 100644
index 0000000..bd2dca2
--- /dev/null
+++ b/types/locale/index.d.ts
@@ -0,0 +1,11 @@
+///
+
+declare module 'dayjs/locale/*' {
+ namespace locale {
+ interface Locale extends ILocale {}
+ }
+
+ const locale: locale.Locale
+
+ export = locale
+}
diff --git a/types/locale/types.d.ts b/types/locale/types.d.ts
new file mode 100644
index 0000000..2c24a64
--- /dev/null
+++ b/types/locale/types.d.ts
@@ -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
+ }>
+}