You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While passing returnObjects: true to ITranslationService .t() I'm getting type match error Type 'string' is not assignable to type 'string[]'.
With returnObjects: true, the return type is supposed to be objects or arrays, but ITranslationService .t() will always return string.
I also checked directly with i18next.t() which works correctly by returning a $SpecialObject, the type is ready to be casted into custom types as described in doc
import*asi18nfrom'i18next';import{ITranslationService}from'angular-i18next';// i18next Correct returning types// goodconst_returnTypeIsString: string=i18n.t('some.string');// goodconst_returnTypeCanBeCasted: string[]=i18n.t('some.string',{returnObjects: true,});// angular-i18next always return string even with returnObjects: true,constservice1: ITranslationService={t: ()=>'',}asunknownasITranslationService;// goodconst_returnTypeShouldBeString: string=service1.t('some.string');// badconst_returnTypeShouldBeCasted: string[]=service1.t('some.string',{returnObjects: true,});// Type 'string' is not assignable to type 'string[]'.(2322)
The text was updated successfully, but these errors were encountered:
Reproduction: angular-i18next issue demo
While passing
returnObjects: true
toITranslationService .t()
I'm getting type match errorType 'string' is not assignable to type 'string[]'.
With
returnObjects: true
, the return type is supposed to be objects or arrays, butITranslationService .t()
will always return string.I also checked directly with i18next.t() which works correctly by returning a
$SpecialObject
, the type is ready to be casted into custom types as described in docThe text was updated successfully, but these errors were encountered: