microsoft / microsoft/TypeScript
In WebView, using Map is not possible.
@rbuckton ci sta già lavorando.
Dal 3/1/2024.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
"iterator", "iterable", "Map", "WebView"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
__values.
⏯ Playground Link
No response
💻 Code
// Your code here
🙁 Actual behavior
I am using RN with a WebView, and the web application uses class-validator. I encountered an error stating 'Object is not iterable.' Upon investigation, I found that the issue comes from the transformation of for...of loops to __values in esm5. (the original code is here)
The class-validator uses Map and it does not have the property length. And in WebView the m is undefined in the following compiled __values. Hence the error is shown.
var __values = (this && this.__values) || function(o) {
// here, o is from the return value of Map instance's entries.
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
So, I fix this issue like following temporarily.
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
if (o.next) return o; // add this line
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
This issue occurs not only with Map but also when using Set in WebView.
🙂 Expected behavior
I can use Map and Set in WebView.
Additional information about the issue
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.