React i18n - "t" 函数不接受字符串变量(打字稿)? "No overload matches this call"
React i18n - "t" function doesn't accept string variables (typescript)? "No overload matches this call"
任何熟悉此错误的人:
[带有错误消息的代码][1]
[1]: https://i.stack.imgur.com/SbJvu.png
{t(`${settingType}` as const)}
错误:
No overload matches this call.
Overload 1 of 2, '(key: TemplateStringsArray | Normalize<{
谢谢:)
解决方法:将t(str)
改为t(str as unknown as TemplateStringArray)
我个人创建了一个辅助函数来这样做,我推荐它。
任何熟悉此错误的人: [带有错误消息的代码][1] [1]: https://i.stack.imgur.com/SbJvu.png
{t(`${settingType}` as const)}
错误:
No overload matches this call.
Overload 1 of 2, '(key: TemplateStringsArray | Normalize<{
谢谢:)
解决方法:将t(str)
改为t(str as unknown as TemplateStringArray)
我个人创建了一个辅助函数来这样做,我推荐它。