Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ts): add missing locale type definitions #716

Merged
merged 2 commits into from Dec 9, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -15,9 +15,9 @@ coverage
# build
/locale
/plugin
dayjs.min.js
/dayjs.min.js
/esm
index.d.ts
/index.d.ts

#dev
demo.js
@@ -1,3 +1,5 @@
/// <reference path="./locale/index.d.ts" />
This conversation was marked as resolved by JounQin

This comment has been minimized.

Copy link
@iamkun

iamkun Nov 6, 2019

Owner

Not sure if we need this reference, can IDE get the path on its own, like our other plugins' types.

This comment has been minimized.

Copy link
@JounQin

JounQin Nov 6, 2019

Author Contributor

No, There is no locale/*.d.ts files except index and types, but other plugins have their own .d.ts.


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?: 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?: 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 }
}
@@ -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
}
@@ -0,0 +1,33 @@
declare interface ILocale {
name: string
This conversation was marked as resolved by JounQin

This comment has been minimized.

Copy link
@iamkun

iamkun Nov 6, 2019

Owner

name is required and others are not

This comment has been minimized.

Copy link
@JounQin

JounQin Nov 6, 2019

Author Contributor

@iamkun Done.

weekdays: string[]
months: string[]
weekStart: number
weekdaysShort: string[]
monthsShort: string[]
weekdaysMin: string[]
ordinal: (n: number) => number | string
formats: {
LT: string
LTS: string
L: string
LL: string
LLL: string
LLLL: string
}
relativeTime: {
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
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.