'what is the type of i18next " t " variable (TYPESCRIPT)

I use i18next and I want to pass the t function prop to my interface.

exp:

const { t } = useTranslation();

export interface ITranslate {
   translate: ... type?
}

what is the type of the " t " variable ?



Solution 1:[1]

You can use ReturnType utility type:

export interface ITranslate {
   translate: ReturnType<typeof useTranslation>['t']
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 smac89