microsoft / microsoft/TypeScript
In WebView, using Map is not possible.
@rbuckton arbeitet bereits daran.
Seit 03.1.2024.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.