【发布时间】:2021-05-24 05:29:17
【问题描述】:
如何在变量函数中编写这个带有泛型参数的打字稿函数(将函数存储在变量中)?
function identity<T>(arg: T): T {
return arg;
}
我试过这个,它抱怨Cannot find name 'React'
const identity = <T>(arg: T): T => {
return arg;
}
【问题讨论】:
-
“不起作用”具体是什么意思?
标签: typescript typescript-generics