i18next-cli 1.70.2 → 1.70.3

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/cjs/cli.js CHANGED
@@ -37,7 +37,7 @@ const program = new commander.Command();
37
37
  program
38
38
  .name('i18next-cli')
39
39
  .description('A unified, high-performance i18next CLI.')
40
- .version('1.70.2'); // This string is replaced with the actual version at build time by rollup
40
+ .version('1.70.3'); // This string is replaced with the actual version at build time by rollup
41
41
  // new: global config override option
42
42
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
43
43
  program
@@ -595,15 +595,14 @@ class ASTVisitors {
595
595
  const extractStringLiteralValue = (node) => {
596
596
  if (!node)
597
597
  return undefined;
598
- // Union (`'a' | 'b'`), local alias, or generic constrained to those: use the
599
- // first member. Mirrors i18next's type-level behaviour (first ns wins).
598
+ // Union (`'a' | 'b'`) or generic constrained to one (`<Ns extends 'a' | 'b'>`):
599
+ // use the first member, mirroring i18next's type-level behaviour (first ns wins).
600
+ // Named aliases (`TFunction<Namespace>`) are deliberately NOT resolved: an
601
+ // app-wide `Namespace` union would otherwise "win" with an arbitrary first entry.
600
602
  if (node.type === 'TsUnionType')
601
603
  return extractStringLiteralValue(node.types?.[0]);
602
604
  if (node.type === 'TsTypeReference' && node.typeName?.type === 'Identifier') {
603
- const constraint = typeParamConstraints[node.typeName.value];
604
- if (constraint)
605
- return extractStringLiteralValue(constraint);
606
- return this.expressionResolver.resolveTypeToStringValues(node)[0];
605
+ return extractStringLiteralValue(typeParamConstraints[node.typeName.value]);
607
606
  }
608
607
  // Handle: typeof SomeConst → TsTypeQuery { exprName: { value: 'SomeConst' } }
609
608
  if (node?.type === 'TsTypeQuery') {
@@ -709,6 +708,11 @@ class ASTVisitors {
709
708
  getObjectTypeMembers(tsType) {
710
709
  if (!tsType)
711
710
  return [];
711
+ // `A & { t: TFunction<'ns'> }` / `(A)` → union of the constituents' members
712
+ if (tsType.type === 'TsIntersectionType')
713
+ return (tsType.types ?? []).flatMap((t) => this.getObjectTypeMembers(t));
714
+ if (tsType.type === 'TsParenthesizedType')
715
+ return this.getObjectTypeMembers(tsType.typeAnnotation);
712
716
  let members;
713
717
  if (tsType.type === 'TsTypeLiteral')
714
718
  members = tsType.members;
package/dist/esm/cli.js CHANGED
@@ -31,7 +31,7 @@ const program = new Command();
31
31
  program
32
32
  .name('i18next-cli')
33
33
  .description('A unified, high-performance i18next CLI.')
34
- .version('1.70.2'); // This string is replaced with the actual version at build time by rollup
34
+ .version('1.70.3'); // This string is replaced with the actual version at build time by rollup
35
35
  // new: global config override option
36
36
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
37
37
  program
@@ -593,15 +593,14 @@ class ASTVisitors {
593
593
  const extractStringLiteralValue = (node) => {
594
594
  if (!node)
595
595
  return undefined;
596
- // Union (`'a' | 'b'`), local alias, or generic constrained to those: use the
597
- // first member. Mirrors i18next's type-level behaviour (first ns wins).
596
+ // Union (`'a' | 'b'`) or generic constrained to one (`<Ns extends 'a' | 'b'>`):
597
+ // use the first member, mirroring i18next's type-level behaviour (first ns wins).
598
+ // Named aliases (`TFunction<Namespace>`) are deliberately NOT resolved: an
599
+ // app-wide `Namespace` union would otherwise "win" with an arbitrary first entry.
598
600
  if (node.type === 'TsUnionType')
599
601
  return extractStringLiteralValue(node.types?.[0]);
600
602
  if (node.type === 'TsTypeReference' && node.typeName?.type === 'Identifier') {
601
- const constraint = typeParamConstraints[node.typeName.value];
602
- if (constraint)
603
- return extractStringLiteralValue(constraint);
604
- return this.expressionResolver.resolveTypeToStringValues(node)[0];
603
+ return extractStringLiteralValue(typeParamConstraints[node.typeName.value]);
605
604
  }
606
605
  // Handle: typeof SomeConst → TsTypeQuery { exprName: { value: 'SomeConst' } }
607
606
  if (node?.type === 'TsTypeQuery') {
@@ -707,6 +706,11 @@ class ASTVisitors {
707
706
  getObjectTypeMembers(tsType) {
708
707
  if (!tsType)
709
708
  return [];
709
+ // `A & { t: TFunction<'ns'> }` / `(A)` → union of the constituents' members
710
+ if (tsType.type === 'TsIntersectionType')
711
+ return (tsType.types ?? []).flatMap((t) => this.getObjectTypeMembers(t));
712
+ if (tsType.type === 'TsParenthesizedType')
713
+ return this.getObjectTypeMembers(tsType.typeAnnotation);
710
714
  let members;
711
715
  if (tsType.type === 'TsTypeLiteral')
712
716
  members = tsType.members;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.70.2",
3
+ "version": "1.70.3",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"version":3,"file":"ast-visitors.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/ast-visitors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAItE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,KAAK,CAAiB;IAE9B,IAAW,UAAU,gBAEpB;IAED,SAAgB,YAAY,EAAE,YAAY,CAAA;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;IACvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAuB;IAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,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