@@ -57,32 +57,31 @@ const getCurrentLocale = ({
57
57
interface Context {
58
58
currentLocale : string
59
59
dateFnsLocale ?: Locale ,
60
- datetime ? : ( date : Date | number , options ?: Intl . DateTimeFormatOptions ) => string ,
61
- formatDate ? : ( value : Date | number | string , options : FormatDateOptions ) => string ,
62
- formatList ? : ( listFormat : [ string | undefined ] , options ?: Intl . ListFormatOptions ) => string ,
63
- formatNumber ? : ( numb : number , options ?: Intl . NumberFormatOptions ) => string ,
64
- formatUnit ? : ( value : number , options : FormatUnitOptions ) => string ,
65
- loadTranslations ? : ( namespace : string , load ?: LoadTranslationsFn ) => Promise < string > ,
66
- locales ? : string [ ] ,
67
- namespaces ? : string [ ] ,
68
- namespaceTranslation ? : ( namespace : string , t ?: TranslateFn ) => TranslateFn
69
- relativeTime ? : ( date : Date | number , options ?: {
60
+ datetime : ( date : Date | number , options ?: Intl . DateTimeFormatOptions ) => string ,
61
+ formatDate : ( value : Date | number | string , options : FormatDateOptions ) => string ,
62
+ formatList : ( listFormat : string [ ] , options ?: Intl . ListFormatOptions ) => string ,
63
+ formatNumber : ( numb : number , options ?: Intl . NumberFormatOptions ) => string ,
64
+ formatUnit : ( value : number , options : FormatUnitOptions ) => string ,
65
+ loadTranslations : ( namespace : string , load ?: LoadTranslationsFn ) => Promise < string > ,
66
+ locales : string [ ] ,
67
+ namespaces : string [ ] ,
68
+ namespaceTranslation : ( namespace : string , t ?: TranslateFn ) => TranslateFn
69
+ relativeTime : ( date : Date | number , options ?: {
70
70
includeSeconds ?: boolean ;
71
71
addSuffix ?: boolean ;
72
72
} ) => string ,
73
- relativeTimeStrict ? : ( date : Date | number , options ?: {
73
+ relativeTimeStrict : ( date : Date | number , options ?: {
74
74
addSuffix ?: boolean ;
75
75
unit ?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' ;
76
76
roundingMethod ?: 'floor' | 'ceil' | 'round' ;
77
77
} ) => string ,
78
- setTranslations ? : React . Dispatch < React . SetStateAction < TranslationsByLocales > > ,
79
- switchLocale ? : ( locale : string ) => void ,
80
- t ? : TranslateFn ,
81
- translations ? : TranslationsByLocales ,
78
+ setTranslations : React . Dispatch < React . SetStateAction < TranslationsByLocales > > ,
79
+ switchLocale : ( locale : string ) => void ,
80
+ t : TranslateFn ,
81
+ translations : TranslationsByLocales ,
82
82
}
83
83
84
- // @ts -expect-error we force the context to undefined, should be corrected with default values
85
- const I18nContext = createContext < Context > ( undefined )
84
+ const I18nContext = createContext < Context | undefined > ( undefined )
86
85
87
86
export const useI18n = ( ) : Context => {
88
87
const context = useContext ( I18nContext )
@@ -214,7 +213,7 @@ const I18nContextProvider = ({
214
213
)
215
214
216
215
const formatList = useCallback (
217
- ( listFormat : [ string | undefined ] , options ?: Intl . ListFormatOptions ) =>
216
+ ( listFormat : string [ ] , options ?: Intl . ListFormatOptions ) =>
218
217
formatters . getListFormat ( currentLocale , options ) . format ( listFormat ) ,
219
218
[ currentLocale ] ,
220
219
)
0 commit comments