Typescript: Incorrect "unreachable code detected" when calling generator

Created on 17 Oct 2017  路  3Comments  路  Source: microsoft/TypeScript




TypeScript Version: 2.6.0-dev.201xxxxx

Code

function f(x: any) {
    console.log(function*() {
        while (true) {}
    }()); // prints a generator { next: [Function], ....etc }
    return 1; // this line is always reached, but compiler reports it as unreachable.
}

console.log(f()) // prints 1
Bug Fixed

Most helpful comment

I often produce unreadable code but this is the first I've heard of the compiler raising a warning about it. 馃槆

All 3 comments

I often produce unreadable code but this is the first I've heard of the compiler raising a warning about it. 馃槆

heh, whoops - title fixed. Thanks.

Seems fixed in latest.

Was this page helpful?
0 / 5 - 0 ratings