i18next 23.15.0 → 23.15.1

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.
@@ -1 +1 @@
1
- {"type":"module","version":"23.15.0"}
1
+ {"type":"module","version":"23.15.1"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next",
3
- "version": "23.15.0",
3
+ "version": "23.15.1",
4
4
  "description": "i18next internationalization framework",
5
5
  "main": "./dist/cjs/i18next.js",
6
6
  "module": "./dist/esm/i18next.js",
@@ -58,3 +58,11 @@ type $StringKeyPathToRecordUnion<
58
58
  export type $StringKeyPathToRecord<TPath extends string, TValue> = $UnionToIntersection<
59
59
  $StringKeyPathToRecordUnion<TPath, TValue>
60
60
  >;
61
+
62
+ /**
63
+ * We could use NoInfer typescript build-in utility,
64
+ * however this project still supports ts < 5.4.
65
+ *
66
+ * @see https://github.com/millsp/ts-toolbelt/blob/master/sources/Function/NoInfer.ts
67
+ */
68
+ export type $NoInfer<A> = [A][A extends any ? 0 : never];
package/typescript/t.d.ts CHANGED
@@ -4,6 +4,7 @@ import type {
4
4
  $Dictionary,
5
5
  $SpecialObject,
6
6
  $StringKeyPathToRecord,
7
+ $NoInfer,
7
8
  } from './helpers.js';
8
9
  import type {
9
10
  TypeOptions,
@@ -260,6 +261,12 @@ export type TFunctionDetailedResult<T = string, TOpt extends TOptions = {}> = {
260
261
  usedParams: InterpolationMap<T> & { count?: TOpt['count'] };
261
262
  };
262
263
 
264
+ type TFunctionProcessReturnValue<Ret, DefaultValue> = Ret extends string | $SpecialObject | null
265
+ ? Ret
266
+ : [DefaultValue] extends [never]
267
+ ? Ret
268
+ : DefaultValue;
269
+
263
270
  type TFunctionReturnOptionalDetails<Ret, TOpt extends TOptions> = TOpt['returnDetails'] extends true
264
271
  ? TFunctionDetailedResult<Ret, TOpt>
265
272
  : Ret;
@@ -278,12 +285,13 @@ export interface TFunction<Ns extends Namespace = DefaultNamespace, KPrefix = un
278
285
  const TOpt extends TOptions,
279
286
  Ret extends TFunctionReturn<Ns, AppendKeyPrefix<Key, KPrefix>, TOpt>,
280
287
  const ActualOptions extends TOpt & InterpolationMap<Ret> = TOpt & InterpolationMap<Ret>,
288
+ DefaultValue extends string = never,
281
289
  >(
282
290
  ...args:
283
291
  | [key: Key | Key[], options?: ActualOptions]
284
- | [key: string | string[], options: TOpt & $Dictionary & { defaultValue: string }]
285
- | [key: string | string[], defaultValue: string, options?: TOpt & $Dictionary]
286
- ): TFunctionReturnOptionalDetails<Ret, TOpt>;
292
+ | [key: string | string[], options: TOpt & $Dictionary & { defaultValue: DefaultValue }]
293
+ | [key: string | string[], defaultValue: DefaultValue, options?: TOpt & $Dictionary]
294
+ ): TFunctionReturnOptionalDetails<TFunctionProcessReturnValue<$NoInfer<Ret>, DefaultValue>, TOpt>;
287
295
  }
288
296
 
289
297
  export type KeyPrefix<Ns extends Namespace> = ResourceKeys<true>[$FirstNamespace<Ns>] | undefined;