在我的 React
应用程序中,我有几种类型:
export interface LocaleData {
languages: Languages, // shows error here
[stringKey: string]: Strings
}
export interface Languages {
[languageKey: string]: string
}
export interface Strings {
login: {
headerGreeting: string,
firstStepGeneralMessage: string,
cellNumber: string,
cellNumberError: string,
areaCodePref: string,
canContinue: string,
signoutAlertTitle: string,
signoutAlertContent: string,
signoutPositiveButton: string
},
////
}
现在,代码运行正常,但我收到一个错误消息:
Property 'languages' of type 'Languages' is not assignable to string index type 'Strings'.
我无法弄清楚所提供的代码有什么问题以及如何避免此错误?