Inference issue while using withTranslation() with TypeScript 3.9
See original GitHub issueI’m trying to upgrade a big project to TypeScript 3.9 but I encounter some typing error caused by the withTranslation
HOC. It seems that props inferring from old prop types definition (for JSX files) don’t work properly.
i18next
: 19.4.4react-i18next
: 11.5.0 (but I also have the issue with versions <10)typescript
: 3.9.3
I created a very small project to reproduce the problem. If you start it, you will see the error of the wrong assignation from the type returned by the withTranslation
HOC.
Type '{ name: string; }' is not assignable to type 'IntrinsicAttributes & Pick<WithTranslation, never> & WithTranslationProps & { children?: ReactNode; }'.
Note that I don’t have this issue with version 3.8 of TypeScript or without this HOC.
Maybe I miss something, don’t hesitate for more info if needed.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
withTranslation (HOC) - react-i18next documentation
When to use? Use the withTranslation HOC to wrap any component (class or function) to access the translation function or i18n instance.
Read more >front-end/node_modules/@material-ui/styles/CHANGELOG.md
A way to get location (latitude and longitude), elevation, speed and other relevant data from individual satellites from the Starlink constellation.
Read more >React and TypeScript Cheatsheets for Developers - Morioh
In this tutorial, we will share a repository of Cheatsheets for experienced React developers getting started with TypeScript. DO NOT MISS!!!
Read more >material-ui/core/CHANGELOG.md - UNPKG
219, - Simplify the theme overrides with TypeScript for the components in the ... 376, - [Snackbar] Fix double click issue on demos...
Read more >TypeScript not inferring function argument type when passing ...
I think this is because of the type inference algorithm that TS uses. It seems that they don't use an unification based algorithm....
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
Hi @clementgarbay I’ve got the same issue than you. Could you share how you’ve solved it ? thx
@xseman I’m having that exact same problem.