【发布时间】:2020-04-26 15:27:43
【问题描述】:
我有一个用例可以用伪代码表示如下:
class Gen<T> {
public doStuff<U>(input: U
/* If T is an instance of number,
then input type U should be an instance of custom type ABC, or
If T is an instance of string,
then input type U should an instance of custom type XYZ, else
compile error */) {
// do stuff with input
}
}
这可以用 TypeScript 表达吗?
【问题讨论】:
标签: typescript generics types