Unable to initialize TFunction for testing after latest version
See original GitHub issueš Bug Report
Hi. Iāve initialized TFunction in my tests before i18next
v22 and i18next
v12, but Iām not able to do that after the upgrade.
To Reproduce
Code before the upgrade
import { TFunction } from 'react-i18next';
import { translationResources } from '../../constants';
const translation: { [key: string]: string } = translationResources.fi.translation;
const t: TFunction<'translation', undefined> = (str: string) => translation[str];
Code after the upgrade
import { TFunction } from 'i18next';
import { translationResources } from '../../constants';
const translation: { [key: string]: string } = translationResources.fi.translation;
const t: TFunction<'translation', undefined> = (str: string) => translation[str];
The error
Type '(str: string) => string' is not assignable to type 'TFunction<"translation", undefined>'.
Type 'string' is not assignable to type 'TFunctionDetailedResult<any>'.
Expected behavior
I expect to be able to initialize TFunction
Your Environment
- runtime version: node v16
- i18next version: 22.0.2
- os: macOS
- typescript: 4.7.4
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Unable to initialize DB for every test method in spring boot
I'm trying to set-up an integration test scenario for spring boot where a fresh H2 database is createdĀ ...
Read more >TestNG fail if there was some exception in test class initialization
Hi! There is a bug in TestNG 5.13.1 (earler versions seems also affected). In case if test class initialization failed, TestNG shows error...
Read more >"Unable to initialize database" error when creating a new SQL ...
Unable to initialize database "twjcq" with schema "WJCQuest" version 42. Reason: SQLExecute: RETCODE=-1, State=37000, Native Error=156 SQLĀ ...
Read more >[FIXED] 'DirectX Failed to Initialize. Please Install the Correct ...
1. How to Fix the āDirectX Failed to Initializeā Error. 2. Update DirectX. 3. Upgrade the DirectX Suite.
Read more >3000s - Application Error Messages
Error number Error message Additional info and instruction
3093 File name missing error Contact Pearson Support.
3105 You must use the TestNav app to take...
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
Thatās a function overload limitation because
TFunction
can have multiple shapes, but it canāt determine the right one if itās not used on the actualt
function. There are a few things that I can do to remove āweightā from theTFunction
and will fix your problem, Iāll keep you posted.Can you try with 22.0.3?