Skip to content

Commit

Permalink
feat: add types to setLocale (#1427)
Browse files Browse the repository at this point in the history
The setLocale file was changed to .ts and the LocaleObject interface was created in locale.ts

Close #1321.
  • Loading branch information
maurodesouza authored Jul 26, 2021
1 parent eab974f commit 7576cd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MixedLocale> = {
default: '${path} is invalid',
required: '${path} is a required field',
Expand Down
4 changes: 2 additions & 2 deletions src/setLocale.js → src/setLocale.ts
Original file line number Diff line number Diff line change
@@ -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];
Expand Down

0 comments on commit 7576cd8

Please sign in to comment.