My interface defines the iterator:
[Symbol.iterator]() : IterableIterator<IDocument>;
My class DocumentManager implements this interface:
*[Symbol.iterator](): IterableIterator<IDocument>{
for(let n of this._documents){// this._documents is Array<IDocument>
yield n;
}
}
In debug mode I see this._documents has three documents, but this code doesn't iteration:
let m = 0;
for(let n of app.documentManager){
++m;
}
// here m == 0 still...
So the iteration doesn't happen. What I did wrong?
UPD
For example, it works in JavaScript:
let collection = {
items : ['a','b','c','d','e'],
*[Symbol.iterator](){
for(let item of this.items){
yield item;
}
}
};
for(let n of collection){
console.log(n);
}
Why I have the problem with TypeScript?
UPD2
Oh, now I see it doesn't work only on the unit test (Karma + Jasmine) but works fine in Node.js. But I need my unit tests work too.... :(((