【发布时间】:2020-02-07 02:22:09
【问题描述】:
我知道这个问题已在其他帖子中介绍过,但我仍然不知道如何进行这项工作 - 我收到了错误:
TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'string | Function' has no compatible call signatures.
控制台记录了一个函数,但我不能调用它。
这是我的代码:
const func = (): string => 'hi';
const array: (string | Function)[][] = [['string', func]];
const response = array[0][1];
console.log(response); // ƒ () { return 'hi'; }
response(); // TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'string | Function' has no compatible call signatures
【问题讨论】:
标签: reactjs typescript