i18next
Advanced tools
Comparing version 23.8.3 to 23.9.0
@@ -1,1 +0,1 @@ | ||
{"type":"module","version":"23.8.3"} | ||
{"type":"module","version":"23.9.0"} |
{ | ||
"name": "i18next", | ||
"version": "23.8.3", | ||
"version": "23.9.0", | ||
"description": "i18next internationalization framework", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/i18next.js", |
@@ -15,2 +15,47 @@ // Types | ||
export type $NormalizeIntoArray<T extends unknown | readonly unknown[]> = T extends readonly unknown[] ? T : [T]; | ||
export type $NormalizeIntoArray<T extends unknown | readonly unknown[]> = | ||
T extends readonly unknown[] ? T : [T]; | ||
/** | ||
* @typeParam T | ||
* @example | ||
* ``` | ||
* $UnionToIntersection<{foo: {bar: string} | {asd: boolean}}> = {foo: {bar: string} & {asd: boolean}} | ||
* ``` | ||
* | ||
* @see https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type | ||
*/ | ||
type $UnionToIntersection<T> = (T extends unknown ? (k: T) => void : never) extends ( | ||
k: infer I, | ||
) => void | ||
? I | ||
: never; | ||
/** | ||
* @typeParam TPath union of strings | ||
* @typeParam TValue value of the record | ||
* @example | ||
* ``` | ||
* $StringKeyPathToRecord<'foo.bar' | 'asd'> = {foo: {bar: string} | {asd: boolean}} | ||
* ``` | ||
*/ | ||
type $StringKeyPathToRecordUnion< | ||
TPath extends string, | ||
TValue, | ||
> = TPath extends `${infer TKey}.${infer Rest}` | ||
? { [Key in TKey]: $StringKeyPathToRecord<Rest, TValue> } | ||
: { [Key in TPath]: TValue }; | ||
/** | ||
* Used to intersect output of {@link $StringKeyPathToRecordUnion} | ||
* | ||
* @typeParam TPath union of strings | ||
* @typeParam TValue value of the record | ||
* @example | ||
* ``` | ||
* $StringKeyPathToRecord<'foo.bar' | 'asd'> = {foo: {bar: string} & {asd: boolean}} | ||
* ``` | ||
*/ | ||
export type $StringKeyPathToRecord<TPath extends string, TValue> = $UnionToIntersection< | ||
$StringKeyPathToRecordUnion<TPath, TValue> | ||
>; |
@@ -1,3 +0,9 @@ | ||
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.js'; | ||
import type { | ||
$OmitArrayKeys, | ||
$PreservedValue, | ||
$Dictionary, | ||
$SpecialObject, | ||
$StringKeyPathToRecord, | ||
} from './helpers.js'; | ||
import type { | ||
TypeOptions, | ||
@@ -143,5 +149,6 @@ Namespace, | ||
: never; | ||
type InterpolationMap<Ret> = Record< | ||
$PreservedValue<ParseInterpolationValues<Ret>, string>, | ||
unknown | ||
type InterpolationMap<Ret> = $PreservedValue< | ||
$StringKeyPathToRecord<ParseInterpolationValues<Ret>, unknown>, | ||
Record<string, unknown> | ||
>; | ||
@@ -148,0 +155,0 @@ |
@@ -1,3 +0,9 @@ | ||
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.js'; | ||
import type { | ||
$OmitArrayKeys, | ||
$PreservedValue, | ||
$Dictionary, | ||
$SpecialObject, | ||
$StringKeyPathToRecord, | ||
} from './helpers.js'; | ||
import type { | ||
TypeOptions, | ||
@@ -10,2 +16,5 @@ Namespace, | ||
/** @todo consider to replace {} with Record<string, never> */ | ||
/* eslint @typescript-eslint/ban-types: ['error', { types: { "{}": false } }] */ | ||
// Type Options | ||
@@ -25,5 +34,2 @@ type _ReturnObjects = TypeOptions['returnObjects']; | ||
/** @todo consider to replace {} with Record<string, never> */ | ||
/* eslint @typescript-eslint/ban-types: ['error', { types: { "{}": false } }] */ | ||
type $IsResourcesDefined = [keyof _Resources] extends [never] ? false : true; | ||
@@ -145,5 +151,6 @@ type $ValueIfResourcesDefined<Value, Fallback> = $IsResourcesDefined extends true | ||
: never; | ||
type InterpolationMap<Ret> = Record< | ||
$PreservedValue<ParseInterpolationValues<Ret>, string>, | ||
unknown | ||
type InterpolationMap<Ret> = $PreservedValue< | ||
$StringKeyPathToRecord<ParseInterpolationValues<Ret>, unknown>, | ||
Record<string, unknown> | ||
>; | ||
@@ -150,0 +157,0 @@ |
632672
14360