11import {
22 assign ,
3+ create ,
34 isNumber ,
45 isFunction ,
56 toDisplayString ,
@@ -16,10 +17,10 @@ type ExtractToStringKey<T> = Extract<keyof T, 'toString'>
1617type ExtractToStringFunction < T > = T [ ExtractToStringKey < T > ]
1718// prettier-ignore
1819type StringConvertable < T > = ExtractToStringKey < T > extends never
19- ? unknown
20- : ExtractToStringFunction < T > extends ( ...args : any ) => string // eslint-disable-line @typescript-eslint/no-explicit-any
21- ? T
22- : unknown
20+ ? unknown
21+ : ExtractToStringFunction < T > extends ( ...args : any ) => string // eslint-disable-line @typescript-eslint/no-explicit-any
22+ ? T
23+ : unknown
2324
2425/** @VueI 18nGeneral */
2526export type Locale = string
@@ -279,27 +280,27 @@ function pluralDefault(choice: number, choicesLength: number): number {
279280 if ( choicesLength === 2 ) {
280281 // prettier-ignore
281282 return choice
282- ? choice > 1
283- ? 1
284- : 0
285- : 1
283+ ? choice > 1
284+ ? 1
285+ : 0
286+ : 1
286287 }
287288 return choice ? Math . min ( choice , 2 ) : 0
288289}
289290
290291function getPluralIndex < T , N > ( options : MessageContextOptions < T , N > ) : number {
291292 // prettier-ignore
292293 const index = isNumber ( options . pluralIndex )
293- ? options . pluralIndex
294- : - 1
294+ ? options . pluralIndex
295+ : - 1
295296 // prettier-ignore
296297 return options . named && ( isNumber ( options . named . count ) || isNumber ( options . named . n ) )
297- ? isNumber ( options . named . count )
298- ? options . named . count
299- : isNumber ( options . named . n )
300- ? options . named . n
301- : index
302- : index
298+ ? isNumber ( options . named . count )
299+ ? options . named . count
300+ : isNumber ( options . named . n )
301+ ? options . named . n
302+ : index
303+ : index
303304}
304305
305306function normalizeNamed ( pluralIndex : number , props : PluralizationProps ) : void {
@@ -336,17 +337,17 @@ export function createMessageContext<T = string, N = {}>(
336337 const list = ( index : number ) : unknown => _list [ index ]
337338
338339 // eslint-disable-next-line @typescript-eslint/no-explicit-any
339- const _named = options . named || ( { } as any )
340+ const _named = options . named || ( create ( ) as any )
340341 isNumber ( options . pluralIndex ) && normalizeNamed ( pluralIndex , _named )
341342 const named = ( key : string ) : unknown => _named [ key ]
342343
343344 function message ( key : Path ) : MessageFunction < T > {
344345 // prettier-ignore
345346 const msg = isFunction ( options . messages )
346- ? options . messages ( key )
347- : isObject ( options . messages )
348- ? options . messages [ key ]
349- : false
347+ ? options . messages ( key )
348+ : isObject ( options . messages )
349+ ? options . messages [ key ]
350+ : false
350351 return ! msg
351352 ? options . parent
352353 ? options . parent . message ( key ) // resolve from parent messages
@@ -412,7 +413,7 @@ export function createMessageContext<T = string, N = {}>(
412413 [ HelperNameMap . TYPE ] : type ,
413414 [ HelperNameMap . INTERPOLATE ] : interpolate ,
414415 [ HelperNameMap . NORMALIZE ] : normalize ,
415- [ HelperNameMap . VALUES ] : assign ( { } , _list , _named )
416+ [ HelperNameMap . VALUES ] : assign ( create ( ) , _list , _named )
416417 }
417418
418419 return ctx
0 commit comments