i18next 25.10.7 → 25.10.9
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/dist/esm/package.json +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/typescript/t.d.ts +27 -8
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"25.10.
|
|
1
|
+
{"type":"module","version":"25.10.9"}
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/typescript/t.d.ts
CHANGED
|
@@ -472,6 +472,23 @@ export type NsResource<Ns extends Namespace> = Ns extends readonly [keyof Resour
|
|
|
472
472
|
/** A selector function that can be used as `keyPrefix` to scope `t()` to a sub-tree of the resource. */
|
|
473
473
|
export type KeyPrefixSelector<Ns extends Namespace> = (src: NsResource<Ns>) => object;
|
|
474
474
|
|
|
475
|
+
/**
|
|
476
|
+
* The type of a selector function accepted by `t()` for a given namespace and optional key prefix.
|
|
477
|
+
* Use this instead of `Parameters<TFunction<Ns>>[0]` for a stable, readable type.
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```ts
|
|
481
|
+
* import type { SelectorParam } from 'i18next';
|
|
482
|
+
*
|
|
483
|
+
* interface CmpProps {
|
|
484
|
+
* i18nKey: SelectorParam<'myNamespace'>;
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
export type SelectorParam<Ns extends Namespace = DefaultNamespace, KPrefix = undefined> = (
|
|
489
|
+
src: Select<GetSource<Ns, KPrefix>, undefined>,
|
|
490
|
+
) => string;
|
|
491
|
+
|
|
475
492
|
/// ////////////// ///
|
|
476
493
|
/// ↆ selector ↆ ///
|
|
477
494
|
/// ////////////// ///
|
|
@@ -514,6 +531,16 @@ type DeepUnwrapPlural<T> =
|
|
|
514
531
|
type NsArg<Ns extends Namespace> = Ns[number] | readonly Ns[number][];
|
|
515
532
|
|
|
516
533
|
interface TFunctionSelector<Ns extends Namespace, KPrefix, Source> extends Branded<Ns> {
|
|
534
|
+
// ── Pre-computed key(s) from keyFromSelector ────────────────────────────────
|
|
535
|
+
// Accepts a branded `SelectorKey` (or array of them) produced by `keyFromSelector`.
|
|
536
|
+
// Return-type precision is traded for the flexibility of decoupled key creation.
|
|
537
|
+
// Placed first so that the more general selector overloads (below) are last —
|
|
538
|
+
// TypeScript's `Parameters<>` utility resolves against the last call signature.
|
|
539
|
+
<const Opts extends SelectorOptions<Ns[number]> = SelectorOptions<Ns[number]>>(
|
|
540
|
+
key: SelectorKey | SelectorKey[],
|
|
541
|
+
...args: [options?: Opts & $Dictionary]
|
|
542
|
+
): DefaultTReturn<Opts>;
|
|
543
|
+
|
|
517
544
|
// ── Selector(s) with explicit `ns` ───────────────────────────────────────────
|
|
518
545
|
<
|
|
519
546
|
Target extends ConstrainTarget<Opts>,
|
|
@@ -593,14 +620,6 @@ interface TFunctionSelector<Ns extends Namespace, KPrefix, Source> extends Brand
|
|
|
593
620
|
? [options: Opts & { count: number } & InterpolationMap<DeepUnwrapPlural<ReturnType<Fn>>>]
|
|
594
621
|
: [options?: Opts & InterpolationMap<ReturnType<Fn>>]
|
|
595
622
|
): SelectorReturn<ReturnType<Fn>, Opts>;
|
|
596
|
-
|
|
597
|
-
// ── Pre-computed key(s) from keyFromSelector ────────────────────────────────
|
|
598
|
-
// Accepts a branded `SelectorKey` (or array of them) produced by `keyFromSelector`.
|
|
599
|
-
// Return-type precision is traded for the flexibility of decoupled key creation.
|
|
600
|
-
<const Opts extends SelectorOptions<Ns[number]> = SelectorOptions<Ns[number]>>(
|
|
601
|
-
key: SelectorKey | SelectorKey[],
|
|
602
|
-
...args: [options?: Opts & $Dictionary]
|
|
603
|
-
): DefaultTReturn<Opts>;
|
|
604
623
|
}
|
|
605
624
|
|
|
606
625
|
interface SelectorOptions<Ns = Namespace>
|