I'm trying to code my own generic iterator class with "DType" and having it a map function which can do a mapping from MyOwnIterator -> MyOwnIterator as the code below:
class MyOwnIterator<DType> {
data:DType[]
constructor (init:DType[]){
this.data=init
}
map<AnotherDType>( func:(item:DType)=>AnotherDType):MyOwnIterator<AnotherDType>{
return new MyOwnIterator(this.data.map(func))
}
}
Now I want to write a more "generic" type for such kind of thing to make MyOwnIterator compatible with it, but how do I write? part below:
type GeneralIterator<DType, IteratorType> = {
map: <T> (func:(item:DType)=>T) => unknown // ???
}
I can't do IteratorType since TS compiler says IteratorType is not a generic