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

Wrong type inferred in for-await-of of Iterable<Promise<any>> #24570

Closed
ajafff opened this issue Jun 1, 2018 · 0 comments
Closed

Wrong type inferred in for-await-of of Iterable<Promise<any>> #24570

ajafff opened this issue Jun 1, 2018 · 0 comments
Assignees
Labels
Bug A bug in TypeScript

Comments

@ajafff
Copy link
Contributor

ajafff commented Jun 1, 2018

TypeScript Version: 3.0.0-dev.20180601

Search Terms: for iterable

Code

// @target: esnext
async function main(p: Iterable<Promise<number>>) {
    for await (const item of p) {
        item; // should be of type 'number'
    }
}

Expected behavior:

item should be of type number to match the runtime value

Actual behavior:

item is incorrectly inferred as Promise<number>

Playground Link: https://agentcooper.github.io/typescript-play/?target=5#code/IYZwngdgxgBAZgV2gFwJYHsIwLbFRACgAcAuGASWQFMAnYAIwBsqAeABRvW1RFYgWz1aAPmEBKGAG8AUDDnx0NGMADueZDAJRMIDamrYY6ODCISZ8yzH1VsAblnyAvtKdA

Related Issues:
#21115 This issue contains a detailed explanation and is not (completely) fixed by the recent changes by @rbuckton

@mhegazy mhegazy added the Bug A bug in TypeScript label Jun 1, 2018
@mhegazy mhegazy added this to the TypeScript 3.0 milestone Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants