i18next 25.10.0 → 25.10.2

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":"25.10.0"}
1
+ {"type":"module","version":"25.10.2"}
package/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import * as i18nextMod from './index.js';
2
2
  import type { $Dictionary } from './typescript/helpers.js';
3
3
 
4
4
  import type { DefaultNamespace, Namespace } from './typescript/options.js';
5
- import type { SelectorKey } from './typescript/t.js';
5
+ import type { KeyFromSelectorFn } from './typescript/t.js';
6
6
 
7
7
  export type WithT<Ns extends Namespace = DefaultNamespace> = i18nextMod.WithT<Ns>;
8
8
  export type Interpolator = i18nextMod.Interpolator;
@@ -59,6 +59,4 @@ export const hasLoadedNamespace: i18n['hasLoadedNamespace'];
59
59
  export const loadNamespaces: i18n['loadNamespaces'];
60
60
  export const loadLanguages: i18n['loadLanguages'];
61
61
 
62
- export declare function keyFromSelector<S = Record<string, any>>(
63
- selector: ($: S) => any,
64
- ): SelectorKey;
62
+ export declare const keyFromSelector: KeyFromSelectorFn;
package/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import type {
12
12
  ResourceLanguage,
13
13
  TOptions,
14
14
  } from './typescript/options.js';
15
- import type { KeyPrefix, TFunction, SelectorKey } from './typescript/t.js';
15
+ import type { KeyPrefix, TFunction, KeyFromSelectorFn } from './typescript/t.js';
16
16
 
17
17
  export interface WithT<Ns extends Namespace = DefaultNamespace> {
18
18
  // Expose parameterized t in the i18next interface hierarchy
@@ -583,6 +583,4 @@ export const hasLoadedNamespace: i18n['hasLoadedNamespace'];
583
583
  export const loadNamespaces: i18n['loadNamespaces'];
584
584
  export const loadLanguages: i18n['loadLanguages'];
585
585
 
586
- export declare function keyFromSelector<S = Record<string, any>>(
587
- selector: ($: S) => any,
588
- ): SelectorKey;
586
+ export declare const keyFromSelector: KeyFromSelectorFn;
package/jsr.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18next/i18next",
3
- "version": "25.10.0",
3
+ "version": "25.10.2",
4
4
  "license": "MIT",
5
5
  "exports": "./src/index.js",
6
6
  "publish": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next",
3
- "version": "25.10.0",
3
+ "version": "25.10.2",
4
4
  "description": "i18next internationalization framework",
5
5
  "main": "./dist/cjs/i18next.js",
6
6
  "module": "./dist/esm/i18next.js",
@@ -49,7 +49,7 @@
49
49
  }
50
50
  ],
51
51
  "dependencies": {
52
- "@babel/runtime": "^7.28.6"
52
+ "@babel/runtime": "^7.29.2"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "typescript": "^5"
@@ -66,16 +66,16 @@
66
66
  "@babel/plugin-transform-modules-commonjs": "^7.28.6",
67
67
  "@babel/plugin-transform-runtime": "^7.29.0",
68
68
  "@babel/polyfill": "^7.12.1",
69
- "@babel/preset-env": "^7.29.0",
69
+ "@babel/preset-env": "^7.29.2",
70
70
  "@babel/preset-react": "^7.28.5",
71
71
  "@babel/register": "^7.28.6",
72
72
  "@rollup/plugin-babel": "^7.0.0",
73
73
  "@rollup/plugin-commonjs": "^29.0.2",
74
74
  "@rollup/plugin-node-resolve": "^16.0.3",
75
75
  "@rollup/plugin-terser": "^1.0.0",
76
- "@types/node": "^25.3.5",
77
- "@typescript-eslint/eslint-plugin": "^8.57.0",
78
- "@typescript-eslint/parser": "^8.57.0",
76
+ "@types/node": "^25.5.0",
77
+ "@typescript-eslint/eslint-plugin": "^8.57.1",
78
+ "@typescript-eslint/parser": "^8.57.1",
79
79
  "@vitest/coverage-v8": "^3.2.4",
80
80
  "babelify": "^10.0.0",
81
81
  "coveralls": "^3.1.1",
@@ -92,10 +92,10 @@
92
92
  "i18next-http-backend": "^3.0.2",
93
93
  "i18next-localstorage-cache": "^1.1.1",
94
94
  "i18next-sprintf-postprocessor": "^0.2.2",
95
- "lint-staged": "^16.3.2",
95
+ "lint-staged": "^16.4.0",
96
96
  "prettier": "^3.8.1",
97
97
  "rimraf": "^6.1.3",
98
- "rollup": "^4.59.0",
98
+ "rollup": "^4.59.1",
99
99
  "sinon": "^19.0.5",
100
100
  "typescript": "^5.9.3",
101
101
  "vitest": "^3.2.4"
package/typescript/t.d.ts CHANGED
@@ -478,6 +478,21 @@ declare const $SelectorKeyBrand: unique symbol;
478
478
  * Can be passed directly to `t()` when the selector API is enabled.
479
479
  */
480
480
  export type SelectorKey = string & { readonly [$SelectorKeyBrand]: typeof $SelectorKeyBrand };
481
+
482
+ /**
483
+ * Type-safe signature for {@link keyFromSelector}.
484
+ * Constrains the selector callback against the default namespace's resources
485
+ * (same source that `t()` uses for selectors without explicit `ns`).
486
+ * When resources are not defined, accepts any selector.
487
+ */
488
+ export type KeyFromSelectorFn = <
489
+ Ns extends Namespace = DefaultNamespace,
490
+ KPrefix extends KeyPrefix<Ns> = undefined,
491
+ >(
492
+ selector: (src: Select<GetSource<Ns, KPrefix>, undefined>) => any,
493
+ opts?: { ns?: Ns; keyPrefix?: KPrefix },
494
+ ) => SelectorKey;
495
+
481
496
  /** Recursively strips the {@link PluralValue} brand from a type (handles nested objects for `returnObjects`). */
482
497
  type DeepUnwrapPlural<T> =
483
498
  T extends PluralValue<infer U>
@@ -657,6 +672,17 @@ type _HasContextVariant<T, K extends string, Context> = [
657
672
  ? false
658
673
  : true;
659
674
 
675
+ /** Checks whether key K has **any** context variant in T (excluding pure plural suffixes). */
676
+ type _IsContextualKey<T, K extends string> = [
677
+ Exclude<
678
+ keyof T & `${K}${_ContextSeparator}${string}`,
679
+ | `${K}${_PluralSeparator}${PluralSuffix}`
680
+ | `${K}${_PluralSeparator}ordinal${_PluralSeparator}${PluralSuffix}`
681
+ >,
682
+ ] extends [never]
683
+ ? false
684
+ : true;
685
+
660
686
  type FilterKeys<T, Context> = never | T extends readonly any[]
661
687
  ? { [I in keyof T]: FilterKeys<T[I], Context> }
662
688
  : $Prune<
@@ -674,7 +700,9 @@ type FilterKeys<T, Context> = never | T extends readonly any[]
674
700
  : K extends string
675
701
  ? _HasContextVariant<T, K, Context> extends true
676
702
  ? never // context variant exists, drop base key (type 3 handles it)
677
- : K // no context variant exists, keep base key
703
+ : _IsContextualKey<T, K> extends true
704
+ ? never // key has context variants but not for this context
705
+ : K // no context variants at all, keep base key
678
706
  : K
679
707
  : K extends `${string}${_PluralSeparator}${PluralSuffix}`
680
708
  ? never