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

Check return types of generator functions. #18729

Closed
wants to merge 1 commit into from

Conversation

brandonbloom
Copy link
Contributor

Fixes #18726

@brandonbloom
Copy link
Contributor Author

Some notes:

  • This doesn't address the done property of IteratorResult, nor does it address the return value of yield expressions.
  • Making the return method have a return type of IteratorResult<any> is awkward, but is actually a more accurate type. If you call next on an iterator manually, you still get an IteratorResult<T> where value is undefined if done is true... unless you return something from a generator function, then you can get anything there.
  • In theory, this only relaxes the type of iterators, so no code should be broken, but I'm sure you guys will validate that.
  • I tried to run generate-diagnostics, but the changes to the .json file didn't seem to get incorporated in to the .js output. Didn't dig in yet, was hoping it's an easy fix with a hint.
  • I'd be happy to help with code to fix Boolean literal types and return type propagation for generators #2983 or yield expressions should be able to acquire the type of generator return types #10509 if provided some guidance. I'm working on an interpreter that abuses co-routines, so these issues affect the bulk of my work.

@typescript-bot
Copy link
Collaborator

Thanks for your contribution. This PR has not been updated in a while and cannot be automatically merged at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to continue working on this PR, please leave a message and one of the maintainers can reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants