You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function* numIterator(num: number) {
var n = parseInt(num.toString()).toString();
var length = n.length;
for (var i = length - 1; i >= 0 ; --i){
yield n.charAt(i);
}
}
Number.prototype[Symbol.iterator] = function() {
return numIterator(this.valueOf());
}
var num = 2387;
for (var n of num){ // Error in VSCode but It works fine in Chrome
console.log(n) // 7, 8, 3, 2
}
The text was updated successfully, but these errors were encountered:
xLama
changed the title
VSCode show me "Type must have a [Symbol.iterator]() method (...) " but Type has it.
VSCode shows me "Type must have a [Symbol.iterator]() method (...) " but Type has it.
Oct 6, 2015
You are augmenting the Number interface without telling the type system about it, so it does not know that a number now has an iterator. you need to augment the declaration of interface Number to add the iterator declaration, so adding something like this to your file should get rid of the error:
I can see that error with this code:
The text was updated successfully, but these errors were encountered: