React 18 type issues -`Type 'TFunctionResult' is not assignable to type 'ReactNode'.
See original GitHub issueType '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:
- Created a year ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I also use
i18nextwithoutreact-i18next. I am experiencing the same issue.You are using i18next in React without react-i18next? Maybe @pedrodurek can advice?