Repository: TypeScript
Issue: Improve Type guards to correctly work with for-of loops
Labels: Bug,Domain: Control Flow

<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨

Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Please read the FAQ first, especially the "Common Feature Requests" section.

-->

## Search Terms
for-of, Type Guard
<!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->

## Suggestion
At the moment a paradigm of call-Parameter-Testing I apply works well in case of one parameter, but if I want to shorten the testing of multiple parameters using a for-of loop the type assertion fails.
<!-- A summary of what you'd like to see added or changed -->

## Use Cases
Correct type guarding of multiple parameters which are supposed to be the same type but to be handled differently
<!--
What do you want to use this for?
What shortcomings exist with current approaches?
-->

## Examples
```ts
type generalObj<T> = {
    value: T,
};

type numObj = generalObj<number>

const isNumObj = (testObj: generalObj<any>): testObj is numObj => {
    //some logic here...
    return true;
}

const numConsumer = (param: numObj) => param;

const shouldWork = (shouldBeNumObj: generalObj<number | string>) => {
    for (const c of [shouldBeNumObj]) {
        if (!isNumObj(c)) {
            return console.error('no numObj')
        }
    }
    // error here despite the right type ensured
    numConsumer(shouldBeNumObj);
}

const doesWork = (shouldBeNumObj: generalObj<number | string>) => {
    if (!isNumObj(shouldBeNumObj)) {
        return console.error('no numObj')
    }
    numConsumer(shouldBeNumObj);
}

const shouldWork2 = (shouldBeNumObj: Array<generalObj<number | string>>) => {
    for (const c of shouldBeNumObj) {
        if (!isNumObj(c)) {
            return console.error('no numObj')
        }
    }
    numConsumer(shouldBeNumObj[0]);
}

const baseTypeNumConsumer = (param: number) => param; 
// curtesy of @nmain
const shouldWork3 = (shouldBeNum: string | number) => {
    for (const v of [shouldBeNum]) {
        if (typeof v !== "number") {
            return;
        }
    }
    baseTypeNumConsumer(shouldBeNum); // compiler error, but should be valid
}

const stringConsumer = (param: generalObj<string>) => param;

const couldBreakCode = (anyObjS: Array<generalObj<any>>) => {
    for (const c of anyObjS) {
        if (!isNumObj(c)) {
            return console.error('no numObj')
        }
    }
    stringConsumer(anyObjS[0])
}

const becauseThisFails = (anyObj: generalObj<any>) => {
    if (!isNumObj(anyObj)) {
        return console.error('no numObj')
    }
    stringConsumer(anyObj);
}
```
<!-- Show how this would be used and what the behavior would be -->

## Checklist

My suggestion meets these guidelines:

* [ ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
    - Could break compilation of already error-prone code where Type testing was disabled with `any `
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).