React 18 type issues -`Type 'TFunctionResult' is not assignable to type 'ReactNode'.

See original GitHub issue

Type 'TFunctionResult' is not assignable to type 'ReactNode'. Type 'object' is not assignable to type 'ReactNode'.ts(2322) [index.d.ts(1360, 9): ]()The expected type comes from property 'children' which is declared here on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'

Tried the following: This solution does not work.

import * as i18next from 'i18next';

// Workaround for https://github.com/isaachinman/next-i18next/issues/1781
declare module 'i18next' {
  interface TFunction {
    <
      TKeys extends i18next.TFunctionKeys = string,
      TInterpolationMap extends object = i18next.StringMap
    >(
      key: TKeys,
      options?: i18next.TOptions<TInterpolationMap> | string,
    ): string;
  }
}

changing ` {t(‘dashboard’)}``to {t<string>(‘dashboard’)} works, but not ideal I need to change it in almost all files.

Related: https://github.com/i18next/react-i18next/issues/1477#issuecomment-1093951936 https://github.com/DefinitelyTyped/DefinitelyTyped/issues/46691 https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Livijncommented, Jul 24, 2022

I also use i18next without react-i18next. I am experiencing the same issue.

1reaction
adraicommented, May 11, 2022

v11.16.4 fixes this

hi there, this assumes one uses react-i18next? (there version of this repo as of writing this comment is 21.8.0)

what if one uses “just” i18next?

You are using i18next in React without react-i18next? Maybe @pedrodurek can advice?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type 'TFunctionResult' is not assignable to type 'ReactNode ...
I was just migrating the app to React 18 and latest TypeScript and faced the same issue. "dependencies" : { "i18next": "^22.0.1", " ......
Read more >
react-i18next on React Native No overload matches this call ...
In the error message, you can find the problem. Type 'TFunctionResult' is not assignable to type 'string | number | TextElement ...
Read more >
type ' ' is not assignable to type 'reactnode' - You.com - You.com
The error is TypeScript's way of telling you that at authoring/compilation time before React tells you that at runtime. Perhaps you meant {listItem.listItem}...
Read more >
@types/react-i18next | Yarn - Package Manager
This is a stub types definition. react-i18next provides its own type definitions, so you do not need this installed. Stub TypeScript definitions entry...
Read more >
TypeScript - react-i18next documentation
Argument of type 'string' is not assignable to parameter of type ... When using the following ...
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