有没有办法说方法的传递类型参数不能是数组?
示例类
class A { public f<T /*which is not array*/>(obj: T) { /* ... */ } }
此代码不会被编译:
const a = new A(); a.f<number[]>([42, 42]);
generics typescript
generics ×1
typescript ×1