Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return statement in iterator is not type checked #30209

Open
agentcooper opened this issue Mar 4, 2019 · 0 comments
Open

Return statement in iterator is not type checked #30209

agentcooper opened this issue Mar 4, 2019 · 0 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@agentcooper
Copy link
Contributor

agentcooper commented Mar 4, 2019

TypeScript Version: 5.3.2.

Search Terms: yield, return, iterator.

Code:

interface Result {
    foo: number;
}

function* gen(): IterableIterator<Result> {
    yield { foo: 1 };
    return { garbage: true }; // not checked
}

(function go(iterator) {
    const { value, done } = iterator.next();
    console.log(value);
    if (!done) {
        go(iterator);
    }
})(gen());

Expected behavior: type error on return statement.

Actual behavior: no type errors.

Playground Link: https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgEoQM4FcA2ZkDeAUMqcjAPYUBcyIWAtgEbQDcRAvkUTFiAmGAUQAKmQBzCCAAUASloBJSFDhMcEJdDhgKUADzpseAHyESZAJ7AIOACaFyVWgEZkHdmWRQIYLFBAO4nBQTHCStGBQWCjuyAD0cXQU+AgAFhAIANYQtpzc0rz8gsISFNLAytq6smaeCMIY+ATIAG5wONEANMi2wjHIALzIFVo6UAB0IBAAHmByHmT1IBgU6uM4FOLSbR0QsgukwDDI0gCEvVM1xJ6e4mUjKmP75qRcHLLSkjKy+0A

Related Issues: #26959.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

3 participants