无法调用类型缺少调用签名的表达式打字稿错误
Cannot invoke an expression whose type lacks a call signature TypeScript error
我无法解决类型兼容性问题。问题在那里:
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;
}
已在评论中解决,请添加,这样就不会再没有答案了:
您对 list
的初始化已关闭。形成你的用法 list
应该是 ListEntry
的数组
let options = {
list: [] as ListEntry[]
};
我无法解决类型兼容性问题。问题在那里:
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;
}
已在评论中解决,请添加,这样就不会再没有答案了:
您对 list
的初始化已关闭。形成你的用法 list
应该是 ListEntry
let options = {
list: [] as ListEntry[]
};