我正在尝试将我在 Vue 中用于处理 i18n 的自定义钩子从 JavaScript 移动到 TypeScript,但我不断收到以下错误:
<块引用>Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Languages'. No index signature with a parameter of type 'string' was found on type 'Languages'.
答案 0 :(得分:0)
Languages
的类型为 { en: object }
,但我怀疑您希望它是一个字符串字典,可以这样输入:
type Languages = {
[locale: string]: Record<string, string>;
}