Open sjordan1975 opened 7 years ago
@christyharagan, what do you make of this? Is the transpiler just doing a bad job, or is there something more serious going on?
You should never use toArray()
when you don’t have to. The whole point of the iterator (i.e. what you get by calling the Symbol.iterator
method) is to not have to eagerly evaluate all of the results. cts.search()
returns a ValueIterator
(in MarkLogic 8) which is (confusingly) bother an iterator and and iterable. I don't know the TypeScript-specific issue here, but here’s a polyfill for ES2016 Map
type that exposes its interface.
Edit: Here’s a better explanation. I can’t tell if IterableIterator
is built-in to TypeScript or something one has to define herself, though.
No, it was just poor typing effort on my behalf. It was a good catch by Salim. I'll put a fix in...
Christy probably fixed this in one of the 0.3.0 to 0.4.2 releases, but it has now moved over to Sequence. Hopefully that works equally well..
@sjordan1975 Would you be able to run a test with the current code in this repo? It is tagged with 0.5.0, but not yet released on NPM..
Here is a snippet of JS that works in QConsole:
Here is the same code written in TS:
Without the
.toArray()
, the resulting JS output from the TS transpiler doesn’t work.