我无法解决类型兼容性的问题。问题在那里:
this.options.list.push(...this.cloudData.map((e: Words) => [e.word, e.size] as[string, number]) as[string, number][]);
options: Options = {
list: [] as ListEntry
};
其中ListEntry
是:
type ListEntry = [string, number];
错误是:
error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: any[]) => number) | ((...items: [string, number][]) => number)' has no compatible call signatures.
有什么想法吗?
编辑
Words
类型:
export class Words {
word: string;
size: number;
}
答案 0 :(得分:1)
解决了评论中的问题,添加为避免未解决的问题:
您对list
的初始化已关闭。您的用法list
应该是ListEntry
let options = {
list: [] as ListEntry[]
};