question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type 'Promise<TFunction>' is missing the following properties from type 'i18n'

See original GitHub issue

Describe the bug Hello,

I’m trying to migrate from lower version to latest one. I updated i18next, react-i18next and solved many issues (like replacing withNamespaces to withTranslation etc.) but I cannot handle one error. I got error TS2740: Type 'Promise<TFunction>' is missing the following properties from type 'i18n': init, loadResources, use, modules, and 26 more.

As you can see I’m using it with Typescript.

import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';

const i18n = i18n
    .use(initReactI18next)
    .init({
        fallbackLng: 'en',
        debug: true,
    });

export default i18n;

The error appears on my tests cases but also if I want to use it with I18nextProvider

import {I18nextProvider} from 'react-i18next';
import i18n from '@/i18n/i18n';

<I18nextProvider i18n={i18n}>
</I18nextProvider>

Occurs in react-i18next version “i18next”: “^15.0.9”, “react-i18next”: “^10.6.2”,

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jamuhlcommented, Apr 6, 2022
// this returns a promise not an i18n instance
export default i18n.use(initReactI18next).init({
  fallbackLng: "en",
  debug: NODE_ENV === "development"
});

this should work:

// don't care for the promise
i18n.use(initReactI18next).init({
  fallbackLng: "en",
  debug: NODE_ENV === "development"
});

// just return the instance you have
export default i18n;

or await the promise (this will only work with top level await support):

export default await i18n.use(initReactI18next).init({
  fallbackLng: "en",
  debug: NODE_ENV === "development"
});
1reaction
rosskevincommented, Apr 9, 2019

If you are mocking and not fulfilling the static type, you’ll need to cast to any.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React ts Type 'Promise<X>' is missing the following properties ...
fetchAllProducts(products ) is a function that returns promise, not an array. To fix it you could write something like:
Read more >
React: Type is missing the following properties from type
js error "Type is missing the following properties from type" occurs when we don't pass any props to a component, or don't pass...
Read more >
TypeScript errors and how to fix them
error TS2740: Type ' TextLine ' is missing the following properties from type ' Position ': line, character, isBefore, isBeforeOrEqual, and 6 more....
Read more >
ECMAScript® 2023 Language Specification - TC39
Properties are containers that hold other objects, primitive values, or functions. A primitive value is a member of one of the following built-in...
Read more >
API Reference | Ajv JSON schema validator
In typescript returned validation function can be a type guard if you pass type ... missing schema can't be loaded ( loadSchema returns...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found