<p dir="auto">This suggestion has a few pieces:</p>
<ol dir="auto">
<li>Implement boolean literal types for <code class="notranslate">true</code> and <code class="notranslate">false</code>, in a fashion similar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="47291043" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/1003" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/1003/hovercard" href="https://github.com/microsoft/TypeScript/issues/1003">#1003</a></li>
<li>Implement type guards for booleans. Essentially, control flow constructs like if-else, while, for, etc would be subject to a type guard if their guard expression is a boolean.</li>
<li>Now we can update generators to have a <code class="notranslate">next</code> method that returns <code class="notranslate">{ done: false; value: TYield; } | { done: true; value: TReturn; }</code>, where TYield is inferred from the yield expressions of a generator, and TReturn is inferred from the return expressions of a generator.</li>
<li>Iterators would return <code class="notranslate">{ done: false; value: TYield; } | { done: true; value: any; }</code> to be compatible with generators.</li>
<li>for-of, spread, array destructuring, and the type yielded by <code class="notranslate">yield*</code> would only pick the value associated with done being false.</li>
<li>The value of a <code class="notranslate">yield*</code> expression would pick the value associated with done being true.</li>
<li>Introduce a Generator type that can be used to track the desired type of a <code class="notranslate">yield</code> expression. This would be TNext, and would be the type of the parameter for the next method on a generator.</li>
</ol>
<p dir="auto">The generator type would look something like this:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface Generator&lt;TYield, TReturn, TNext&gt; extends IterableIterator&lt;TYield&gt; {
    next(value?: TNext): IteratorYieldResult&lt;TYield&gt; | IteratorReturnResult&lt;TReturn&gt;;
    throw(exception: any): IteratorYieldResult&lt;TYield&gt; | IteratorReturnResult&lt;TReturn&gt;;
    return(value: any): IteratorYieldResult&lt;TYield&gt; | IteratorReturnResult&lt;TReturn&gt;;
    [Symbol.iterator](): Generator&lt;TYield, TReturn, TNext&gt;;
    [Symbol.toStringTag]: string;
}"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">Generator</span><span class="pl-c1">&lt;</span><span class="pl-smi">TYield</span><span class="pl-kos">,</span> <span class="pl-smi">TReturn</span><span class="pl-kos">,</span> <span class="pl-smi">TNext</span><span class="pl-c1">&gt;</span> <span class="pl-k">extends</span> <span class="pl-smi">IterableIterator</span><span class="pl-kos">&lt;</span><span class="pl-smi">TYield</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c1">next</span><span class="pl-kos">(</span><span class="pl-s1">value</span>?: <span class="pl-smi">TNext</span><span class="pl-kos">)</span>: <span class="pl-smi">IteratorYieldResult</span><span class="pl-kos">&lt;</span><span class="pl-smi">TYield</span><span class="pl-kos">&gt;</span> <span class="pl-c1">|</span> <span class="pl-smi">IteratorReturnResult</span><span class="pl-kos">&lt;</span><span class="pl-smi">TReturn</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
    <span class="pl-c1">throw</span><span class="pl-kos">(</span><span class="pl-s1">exception</span>: <span class="pl-smi">any</span><span class="pl-kos">)</span>: <span class="pl-smi">IteratorYieldResult</span><span class="pl-kos">&lt;</span><span class="pl-smi">TYield</span><span class="pl-kos">&gt;</span> <span class="pl-c1">|</span> <span class="pl-smi">IteratorReturnResult</span><span class="pl-kos">&lt;</span><span class="pl-smi">TReturn</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
    <span class="pl-c1">return</span><span class="pl-kos">(</span><span class="pl-s1">value</span>: <span class="pl-smi">any</span><span class="pl-kos">)</span>: <span class="pl-smi">IteratorYieldResult</span><span class="pl-kos">&lt;</span><span class="pl-smi">TYield</span><span class="pl-kos">&gt;</span> <span class="pl-c1">|</span> <span class="pl-smi">IteratorReturnResult</span><span class="pl-kos">&lt;</span><span class="pl-smi">TReturn</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
    <span class="pl-kos">[</span><span class="pl-smi">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">iterator</span><span class="pl-kos">]</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">Generator</span><span class="pl-kos">&lt;</span><span class="pl-smi">TYield</span><span class="pl-kos">,</span> <span class="pl-smi">TReturn</span><span class="pl-kos">,</span> <span class="pl-smi">TNext</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
    <span class="pl-kos">[</span><span class="pl-smi">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">toStringTag</span><span class="pl-kos">]</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">If one try to set a property that hasn't any getter defined, the compiler doesn't emit any error or warning and the code silently fails à runtime.</p>
<p dir="auto">example:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Greeter {
    private _greeting: string;
    get greeting(): string { return this._greeting; }

    constructor(message: string) {
        this.greeting = message; //no error at compile time and silent failure at execution time
    }
    greet() {
        return &quot;Hello, &quot; + this.greeting;
    }
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">Greeter</span> <span class="pl-kos">{</span>
    <span class="pl-k">private</span> <span class="pl-c1">_greeting</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
    <span class="pl-k">get</span> <span class="pl-en">greeting</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">string</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">_greeting</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>

    <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-s1">message</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">greeting</span> <span class="pl-c1">=</span> <span class="pl-s1">message</span><span class="pl-kos">;</span> <span class="pl-c">//no error at compile time and silent failure at execution time</span>
    <span class="pl-kos">}</span>
    <span class="pl-en">greet</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-s">"Hello, "</span> <span class="pl-c1">+</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">greeting</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>