🐛 Bug Report
For an non-default namespace (ex: an extra namespace with { "testing": "extra string" }), key suggestions are being shown without the namespace.
Suggestions show
const { t } = useTranslation(["common", "extra"]);
t('test') // "testing" shows up in TS autocomplete, but should not
Gives expected TS error after writing testing
Argument of type '"testing"' is not assignable to parameter of type 'TemplateStringsArray | "extra:testing" | "common:documentation" | "common:loading" | "common:this-stack-uses" | "common:techcard" | "common:techcard.nextjs" | "common:techcard.prisma" | "common:techcard.nextjs.description" | "common:techcard.prisma.description" | (TemplateStringsArray | ... 8 more ... | "common:tech...'.typescript(2769)
To Reproduce
Set up TS as per preferred approach, with objects declared as const.
Created an extra namespace with a single testing key.
i18next.d.ts
import "i18next";
import locales from "./public/locales";
declare module "i18next" {
interface CustomTypeOptions {
defaultNS: "common";
resources: typeof locales["en"];
}
}
public/locales/en/extra.json
{
"testing": "extra string"
}
Codesandboxes:
22.4.5
22.4.2
22.4.1 (not reproducible)
Also reproducible in https://github.com/BearStudio/start-ui-web by upgrading i18next to 22.4.2-5
22.4.2+

22.4.1

Expected behavior
Suggestions should not omit namespaces for non-default key values.
const { t } = useTranslation(["common", "extra"]);
t('testi') // "testing" does not show up in TS autocomplete, only "extra:testing"
Your Environment
- runtime version: i.e. node 18.12.1
- i18next version: i.e. 22.4.2 to 22.4.5
- os: WSL2 Linux
🐛 Bug Report
For an non-default namespace (ex: an
extranamespace with{ "testing": "extra string" }), key suggestions are being shown without the namespace.Suggestions show
Gives expected TS error after writing
testingTo Reproduce
Set up TS as per preferred approach, with objects declared
as const.Created an extra namespace with a single
testingkey.i18next.d.tspublic/locales/en/extra.json{ "testing": "extra string" }Codesandboxes:
22.4.5
22.4.2
22.4.1 (not reproducible)
Also reproducible in https://github.com/BearStudio/start-ui-web by upgrading i18next to 22.4.2-5
22.4.2+

22.4.1

Expected behavior
Suggestions should not omit namespaces for non-default key values.
Your Environment