react-i18next 11.15.3 → 11.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 11.15.6
2
+
3
+ - fix error for typescript 4.6 [1453](https://github.com/i18next/react-i18next/pull/1463)
4
+
5
+ ### 11.15.5
6
+
7
+ - types: fix never return type when using plurals [1453](https://github.com/i18next/react-i18next/pull/1453)
8
+
9
+ ### 11.15.4
10
+
11
+ - types: add values field to Plural component in macros [1446](https://github.com/i18next/react-i18next/pull/1446)
12
+
1
13
  ### 11.15.3
2
14
 
3
15
  - types: fix for issue introduced with type extension for react-native [1436](https://github.com/i18next/react-i18next/pull/1436)
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 i18next
3
+ Copyright (c) 2022 i18next
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-i18next",
3
- "version": "11.15.3",
3
+ "version": "11.15.6",
4
4
  "description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "types": "./index.d.ts",
@@ -86,7 +86,7 @@
86
86
  "rollup-plugin-terser": "^5.1.1",
87
87
  "sinon": "^7.2.3",
88
88
  "tslint": "^5.20.1",
89
- "typescript": "^4.5.2",
89
+ "typescript": "4.6.2",
90
90
  "yargs": "^13.3.0"
91
91
  },
92
92
  "peerDependencies": {
@@ -14,6 +14,7 @@ declare module 'react-i18next/icu.macro' {
14
14
  i18n?: i18n;
15
15
  ns?: N;
16
16
  count: number;
17
+ values?: {};
17
18
  zero?: string | React.ReactElement;
18
19
  one?: string | React.ReactElement;
19
20
  two?: string | React.ReactElement;
package/ts4.1/index.d.ts CHANGED
@@ -95,8 +95,10 @@ declare module 'i18next' {
95
95
  }
96
96
  }
97
97
 
98
+ type PluralSuffix = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
99
+
98
100
  type WithOrWithoutPlural<K> = TypeOptions['jsonFormat'] extends 'v4'
99
- ? K extends `${infer B}_${'zero' | 'one' | 'two' | 'few' | 'many' | 'other'}`
101
+ ? K extends `${infer B}_${PluralSuffix}`
100
102
  ? B | K
101
103
  : K
102
104
  : K;
@@ -150,6 +152,12 @@ export type NormalizeByTypeOptions<
150
152
  R = TypeOptionsFallback<TranslationValue, Options['returnEmptyString'], ''>
151
153
  > = TypeOptionsFallback<R, Options['returnNull'], null>;
152
154
 
155
+ type StringIfPlural<T> = TypeOptions['jsonFormat'] extends 'v4'
156
+ ? T extends `${string}_${PluralSuffix}`
157
+ ? string
158
+ : never
159
+ : never;
160
+
153
161
  type NormalizeReturn<
154
162
  T,
155
163
  V,
@@ -162,7 +170,7 @@ type NormalizeReturn<
162
170
  ? K extends keyof T
163
171
  ? NormalizeReturn<T[K], R>
164
172
  : never
165
- : never;
173
+ : StringIfPlural<keyof T>;
166
174
 
167
175
  type NormalizeMultiReturn<T, V> = V extends `${infer N}:${infer R}`
168
176
  ? N extends keyof T
@@ -319,7 +327,7 @@ export function withTranslation<N extends Namespace = DefaultNamespace>(
319
327
  withRef?: boolean;
320
328
  },
321
329
  ): <
322
- C extends React.ComponentType<React.ComponentProps<C> & WithTranslationProps>,
330
+ C extends React.ComponentType<React.ComponentProps<any> & WithTranslationProps>,
323
331
  ResolvedProps = JSX.LibraryManagedAttributes<
324
332
  C,
325
333
  Subtract<React.ComponentProps<C>, WithTranslationProps>