【发布时间】:2021-07-05 04:20:14
【问题描述】:
最小的工作示例:
type FuncType<T> = (a: T) => T;
let f1: FuncType<T>; // does not compile
let f2: <T>(a: T) => T; // compiles
问题是FuncType不是我定义的,而是来自一个库。它也比上面的例子复杂得多。我想使用从库中导出的模板类型,而不必自己重新声明它(就像我在注释 f2 时所做的那样)。
有可能吗?如果没有,你知道为什么不吗?
感谢您的任何意见,我找不到有关此主题的任何内容
【问题讨论】:
-
declare let f1: FuncType<T>; -
不使用 TS
4.2.3编译 - 你使用的是哪个编译器版本 @RobertoZvjerković?
标签: typescript templates generics types typescript-generics