Skip to content

return incorrectly considered to be yielded #22298

Closed
@ghost

Description

TypeScript Version: 2.8.0-dev.20180302

Code

function* f() {
    yield 0;
    return "";
}

for (const x of f()) {
    const n: number = x;
}

Expected behavior:

No error.

Actual behavior:

src/a.ts(7,11): error TS2322: Type '"" | 0' is not assignable to type 'number'.
  Type '""' is not assignable to type 'number'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions