Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t function with plurals returns type never after migrating to v21.x.x #1451

Closed
wolkyura opened this issue Feb 16, 2022 · 2 comments · Fixed by #1453
Closed

t function with plurals returns type never after migrating to v21.x.x #1451

wolkyura opened this issue Feb 16, 2022 · 2 comments · Fixed by #1453
Assignees

Comments

@wolkyura
Copy link

🐛 Bug Report

After upgrading i18next to latest version from 20.x.x version, t('ns:key', { count: 1 }) function with count option always returns value with type never (on version 20.x.x - string as expected)

Screen Shot 2022-02-16 at 3 32 37 PM

To Reproduce

{
  "key_one": "value",
  "key_other": "values"
}
const { t } = useTranslation(['common']);
const value = t('common:key', { count: 10 }); // type of value - `never`

react-18next.d.ts:

import { resources } from './i18n';

declare module 'react-i18next' {
  interface CustomTypeOptions {
    resources: typeof resources['en'];
  }
}

i18n.ts:

import i18n from 'i18next';
import detector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';

import { en } from './locales/en';

export const resources = {
  en,
} as const;

i18n
  .use(detector)
  .use(initReactI18next)
  .init({
    interpolation: {
      escapeValue: false,
    },
    lng: 'en',
    resources,
  });

export default i18n;

Expected behavior

I would expect string type of returning value t('common:key', { count: 10 })

const { t } = useTranslation(['common']);
const value = t('common:key', { count: 10 }); // type of value - `string`

Your Environment

  • runtime version: node v14
  • i18next version: 21.6.6
  • react-i18next: 11.15.3,
  • os: Mac
@wolkyura wolkyura changed the title t function with plurals return type never after migrating to v21.x.x t function with plurals returns type never after migrating to v21.x.x Feb 16, 2022
@pedrodurek
Copy link
Member

Hey @wolkyura, that's definitely a bug, I'll try to fix it today

@adrai
Copy link
Member

adrai commented Feb 22, 2022

fixed with v11.15.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants