react-i18next
Advanced tools
Comparing version 11.11.3 to 11.11.4
@@ -0,1 +1,5 @@ | ||
### 11.11.4 | ||
- typescript: add returnNull and returnEptyString options to TypeOptions interface [1341](https://github.com/i18next/react-i18next/pull/1341) | ||
### 11.11.3 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "react-i18next", | ||
"version": "11.11.3", | ||
"version": "11.11.4", | ||
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js", |
@@ -29,3 +29,3 @@ import i18next, { | ||
/** | ||
* This interface can be augmented by users to add types to `react-i18next`. It accepts a `defaultNS` and `resources` properties. | ||
* This interface can be augmented by users to add types to `react-i18next`. It accepts a `defaultNS`, `resources`, `returnNull` and `returnEmptyString` properties. | ||
* | ||
@@ -39,2 +39,4 @@ * Usage: | ||
* defaultNS: 'custom'; | ||
* returnNull: false, | ||
* returnEmptyString: false, | ||
* resources: { | ||
@@ -55,2 +57,4 @@ * custom: { | ||
{ | ||
returnNull: true; | ||
returnEmptyString: true; | ||
defaultNS: 'translation'; | ||
@@ -117,2 +121,22 @@ resources: Resources; | ||
type CustomTypeParameters = { | ||
returnNull?: boolean; | ||
returnEmptyString?: boolean; | ||
}; | ||
type TypeOptionsFallback<TranslationValue, Option, MatchingValue> = Option extends false | ||
? TranslationValue extends MatchingValue | ||
? string | ||
: TranslationValue | ||
: TranslationValue; | ||
/** | ||
* Checks if user has enabled `returnEmptyString` and `returnNull` options to retrieve correct values. | ||
*/ | ||
export type NormalizeByTypeOptions< | ||
TranslationValue, | ||
Options extends CustomTypeParameters = TypeOptions, | ||
R = TypeOptionsFallback<TranslationValue, Options['returnEmptyString'], ''> | ||
> = TypeOptionsFallback<R, Options['returnNull'], null>; | ||
type NormalizeReturn<T, V> = V extends `${infer K}.${infer R}` | ||
@@ -123,3 +147,3 @@ ? K extends keyof T | ||
: V extends keyof T | ||
? T[V] | ||
? NormalizeByTypeOptions<T[V]> | ||
: never; | ||
@@ -126,0 +150,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
334164
5911