diff --git a/src/locale.ts b/src/locale.ts index d5efe7987..5aaf6ed0b 100644 --- a/src/locale.ts +++ b/src/locale.ts @@ -52,6 +52,16 @@ export interface BooleanLocale { isValue?: Message; } +export interface LocaleObject { + mixed?: MixedLocale; + string?: StringLocale; + number?: NumberLocale; + date?: DateLocale; + boolean?: BooleanLocale; + object?: ObjectLocale; + array?: ArrayLocale; +} + export let mixed: Required = { default: '${path} is invalid', required: '${path} is a required field', diff --git a/src/setLocale.js b/src/setLocale.ts similarity index 59% rename from src/setLocale.js rename to src/setLocale.ts index ce0c3850e..171ea95ab 100644 --- a/src/setLocale.js +++ b/src/setLocale.ts @@ -1,6 +1,6 @@ -import locale from './locale'; +import locale, { LocaleObject } from './locale'; -export default function setLocale(custom) { +export default function setLocale(custom: LocaleObject) { Object.keys(custom).forEach(type => { Object.keys(custom[type]).forEach(method => { locale[type][method] = custom[type][method];