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
When you use a string union as the context parameter it's possible to supply values for which a context does not exist and it does not result in an error. If you just use the plain string value or a const it works.
constApp=()=>{const{ t }=useTranslation('translation');return(<div><p>{t('testContext1',{context: 'Test1'as'Test1'|'Test2'|'Test3'})}</p><p>{t('testContext1',{context: 'Test2'})}</p><p>{t('testContext1',{context: 'Test2'asconst})}</p><p>{t('testContext1',{context: 'Test3'as'Test1'|'Test2'|'Test3'})}</p>{/* Error: Type '{ context: "Test3"; }' is not assignable to type 'string' */}<p>{t('testContext1',{context: 'Test3'})}</p>{/* Error: Type '{ context: "Test3"; }' is not assignable to type 'string' */}<p>{t('testContext1',{context: 'Test3'asconst})}</p></div>);};
Expected behavior
String unions should be correctly detected as errors if they have cases which are not covered by the context.
Your Environment
runtime version: i.e. node v14, deno, browser xy
i18next version: i.e. 19.5.3
os: Mac, Windows, Linux
any other relevant information
The text was updated successfully, but these errors were encountered:
This issue is an upstream issue, so it should be handled in i18next not react-i18next. @adrai can the issue be moved there or it needs to be closed and reopened there?
馃悰 Bug Report
When you use a string union as the context parameter it's possible to supply values for which a context does not exist and it does not result in an error. If you just use the plain string value or a const it works.
To Reproduce
A minimal reproducible example.
Expected behavior
String unions should be correctly detected as errors if they have cases which are not covered by the context.
Your Environment
The text was updated successfully, but these errors were encountered: