Answer the question
In order to leave comments, you need to log in
How to determine the type of a variable in a loop?
Hello everyone,
There is a loop (TypeScript):
How to determine the type for the variable `some`?
It is impossible to take it out, the correct formation of the scope will be lost. for (let some of data) { ... }
Answer the question
In order to leave comments, you need to log in
So it is necessary not for some, but for data to determine the type.
const myIterable: unknown = [1,2,3,4,5];
for (const entry of <IterableIterator<number>>myIterable) {
console.log(entry);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question