i18next 23.7.16 → 23.7.18

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.7.16"}
1
+ {"type":"module","version":"23.7.18"}
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Internal Helpers
2
- import type { $Dictionary } from './typescript/helpers.js';
2
+ import type { $Dictionary, $NormalizeIntoArray } from './typescript/helpers.js';
3
3
  import type {
4
4
  DefaultNamespace,
5
5
  FlatNamespace,
@@ -217,12 +217,22 @@ export interface CloneOptions extends InitOptions {
217
217
  forkResourceStore?: boolean;
218
218
  }
219
219
 
220
- export interface CustomInstanceExtenstions {}
220
+ export interface CustomInstanceExtensions {}
221
+
222
+ // Used just here to exclude `DefaultNamespace` which can be both string or array from `FlatNamespace`
223
+ // in TFunction declaration below.
224
+ // Due to this only very special usage I'm not moving this inside helpers.
225
+ type InferArrayValuesElseReturnType<T> = T extends (infer A)[] ? A : T;
221
226
 
222
227
  // eslint-disable-next-line @typescript-eslint/naming-convention
223
- export interface i18n extends CustomInstanceExtenstions {
228
+ export interface i18n extends CustomInstanceExtensions {
224
229
  // Expose parameterized t in the i18next interface hierarchy
225
- t: TFunction<[DefaultNamespace, ...Exclude<FlatNamespace, DefaultNamespace>[]]>;
230
+ t: TFunction<
231
+ [
232
+ ...$NormalizeIntoArray<DefaultNamespace>,
233
+ ...Exclude<FlatNamespace, InferArrayValuesElseReturnType<DefaultNamespace>>[],
234
+ ]
235
+ >;
226
236
 
227
237
  /**
228
238
  * The default of the i18next module is an i18next instance ready to be initialized by calling init.
package/index.v4.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Internal Helpers
2
- import type { $Dictionary } from './typescript/helpers.js';
2
+ import type { $Dictionary, $NormalizeIntoArray } from './typescript/helpers.js';
3
3
  import type {
4
4
  DefaultNamespace,
5
5
  FlatNamespace,
@@ -217,12 +217,22 @@ export interface CloneOptions extends InitOptions {
217
217
  forkResourceStore?: boolean;
218
218
  }
219
219
 
220
- export interface CustomInstanceExtenstions {}
220
+ export interface CustomInstanceExtensions {}
221
+
222
+ // Used just here to exclude `DefaultNamespace` which can be both string or array from `FlatNamespace`
223
+ // in TFunction declaration below.
224
+ // Due to this only very special usage I'm not moving this inside helpers.
225
+ type InferArrayValuesElseReturnType<T> = T extends (infer A)[] ? A : T;
221
226
 
222
227
  // eslint-disable-next-line @typescript-eslint/naming-convention
223
- export interface i18n extends CustomInstanceExtenstions {
228
+ export interface i18n extends CustomInstanceExtensions {
224
229
  // Expose parameterized t in the i18next interface hierarchy
225
- t: TFunction<[DefaultNamespace, ...Exclude<FlatNamespace, DefaultNamespace>[]]>;
230
+ t: TFunction<
231
+ [
232
+ ...$NormalizeIntoArray<DefaultNamespace>,
233
+ ...Exclude<FlatNamespace, InferArrayValuesElseReturnType<DefaultNamespace>>[],
234
+ ]
235
+ >;
226
236
 
227
237
  /**
228
238
  * The default of the i18next module is an i18next instance ready to be initialized by calling init.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next",
3
- "version": "23.7.16",
3
+ "version": "23.7.18",
4
4
  "description": "i18next internationalization framework",
5
5
  "main": "./dist/cjs/i18next.js",
6
6
  "module": "./dist/esm/i18next.js",
@@ -101,12 +101,13 @@
101
101
  "vitest": "1.1.0"
102
102
  },
103
103
  "scripts": {
104
- "lint": "eslint src typescript \"./*.{ts,mts}\"",
104
+ "lint": "eslint src typescript test \"./*.{ts,mts}\"",
105
105
  "pretest": "npm run generate_ts_v4_index && npm run lint",
106
- "test": "vitest --typecheck --workspace vitest.workspace.mts --run",
107
- "test:runtime": "vitest --workspace vitest.workspace.mts --project runtime",
108
- "test:compatibility": "vitest --workspace vitest.workspace.mts --project compatibility",
109
- "test:coverage": "npm run test:runtime -- --coverage --run",
106
+ "test": "vitest --run",
107
+ "test:coverage": "vitest --project runtime --project compatibility --coverage --run",
108
+ "test:runtime": "vitest --project runtime",
109
+ "test:compatibility": "vitest --project compatibility",
110
+ "test:local": "vitest --workspace vitest.workspace.local.mts",
110
111
  "build": "rimraf dist && rollup -c && echo '{\"type\":\"module\"}' > dist/esm/package.json && cpy \"./dist/umd/*.js\" ./",
111
112
  "generate_ts_v4_index": "cp index.d.ts index.v4.d.ts && node -e \"fs.writeFileSync('index.v4.d.ts', fs.readFileSync('index.v4.d.ts').toString().replace(/t.js/g, 't.v4.js').replace(/export type \\* /g, '// export type * '))\"",
112
113
  "fix_dist_package": "node -e 'console.log(`{\"type\":\"module\",\"version\":\"${process.env.npm_package_version}\"}`)' > dist/esm/package.json",
@@ -1,5 +1,15 @@
1
- export type $MergeBy<T, K> = Omit<T, keyof K> & K;
1
+ // Types
2
+
2
3
  export type $Dictionary<T = unknown> = { [key: string]: T };
4
+
5
+ export type $SpecialObject = object | Array<string | object>;
6
+
7
+ // Types Operators
8
+
9
+ export type $MergeBy<T, K> = Omit<T, keyof K> & K;
10
+
3
11
  export type $OmitArrayKeys<Arr> = Arr extends readonly any[] ? Omit<Arr, keyof any[]> : Arr;
12
+
4
13
  export type $PreservedValue<Value, Fallback> = [Value] extends [never] ? Fallback : Value;
5
- export type $SpecialObject = object | Array<string | object>;
14
+
15
+ export type $NormalizeIntoArray<T extends unknown | readonly unknown[]> = T extends readonly unknown[] ? T : [T];