t
function fully-type safe (keys
and return
type).react-i18next.d.ts
), for example:i18n.ts
react-i18next.d.ts
t
function should be fully typed by now.t
function, we recursively map all nested keys from your primary locale files or objects. Depending on the number of keys your project have, the compilation time could be noticeably affected. If this is negatively influencing your productivity, this feature might not be the best choice for you. In our tests, we got great results when declaring up to 7000 keys, but it may vary according to the project size as well. If needed, you can always open an issue on Github to get some help from us.Argument of type 'string' is not assignable to parameter of type ...
key
as string, which will cause to throw the error above. In this case, you will need to assert the template string as const
, like this:t
function, like this:keys
and return
type inference will not work, because TemplateStringsArray does not accept generic types yet. You can use Tagged Template Literal syntax, but it will accept any string as argument.