export {}
type F =
((a: string) => void) |
((b: boolean) => void)
let f: F = (a: string) => {}
f('foo')
function f2 (f: F) {
f('foo')
^^^^^
}
为什么光标处会出现这个错误呢?
[ts] Cannot invoke an expression whose type lacks a call signature. Type 'F' has no compatible call signatures.
PS. 唉头一次写 typescript 程序,碰到无数问题。typescript 要在本来无类型的 js 上面加类型搞出来的东西貌似比 java 的类型系统坑多(当然也灵活的多)