Skip to content

t() return type is never if using key from fallbackNS #2360

@leobenzol

Description

@leobenzol

🐛 Bug Report

If you setup an i18n instance with 2 ns(the default translation and custom) and with fallbackNS: translation
and then create a t<"custom"> instance, calling t("keyFromTranslationNS") will return "never" instead of "string"

To Reproduce

I modified one of the react-i18next examples: made a repo for convinience. The last commit is all the changes i made over the example

Expected behavior

Using t("fallbackKey") should return "string", not "never"

I tested it and i'm prettu sure it would be as simple as changing the line: https://github.com/i18next/i18next/blob/master/typescript/t.d.ts#L247
with: $PreservedValue<ParseTReturn<ActualKey, Resources[$FirstNamespace<ActualNS>], TOpt>, ParseTReturn<ActualKey, Resources[_FallbackNamespace], TOpt>>

Your Environment

  • runtime version: node 20
  • i18next version: 25.6.0
  • os: Mac

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions