[英]“Cannot find param” on defining function type returning a function in TypeScript
I have trouble with defining a function type that returns another function in TypeScript. 我很难定义一个在TypeScript中返回另一个函数的函数类型。
This works: 这有效:
type HandleDoc = (doc: any) => any
type SyncHookDoc = (updateStore, doc: any, store) => (void | HandleDoc)
But if I try in 1 line it does not work: 但是,如果我尝试1行,则不起作用:
type SyncHookDoc = (updateStore, doc: any, store) => (void | (doc: any) => any)
Errors:
错误:
Cannot find name 'doc'.
找不到名称“ doc”。
'any' only refers to a type, but is being used as a value here.
“ any”仅指类型,但在此处被用作值。
您需要在函数签名周围附加一组()
:
type SyncHookDoc = (updateStore, doc: any, store) => (void | ((doc: any) => any))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.