Skip to content

Conversation

@rbuckton
Copy link
Contributor

@rbuckton rbuckton commented Jul 8, 2019

Allow generator return type inference to fall back to IterableIterator if Generator can't be found and the return and next types of the generator are compatible with the expected return and next types of IterableIterator.

This improves backwards compatibility for existing generators that may not have the es2015.generators lib included.

Fixes https://github.com/microsoft/TypeScript/pull/32244/files#diff-601ae163618e1a582913605ac0b1b7c1R107

@rbuckton
Copy link
Contributor Author

rbuckton commented Jul 8, 2019

@DanielRosenwasser: Interested in your feedback. The problem is that Generator (and AsyncGenerator) are under different default libs than IterableIterator (and AsyncIterableIterator), so existing projects could have new errors if they have explicit "lib" settings. The basic idea here is that when we infer a return type for a generator function, if we can't find Generator we will use IterableIterator as the return type if the return and next types are assignment compatible rather than reporting an error. However, we will always use Generator if we can find it.

@rbuckton
Copy link
Contributor Author

rbuckton commented Jul 8, 2019

@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 8, 2019

Heya @rbuckton, I've started to run the parallelized community code test suite on this PR at d045eab. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@rbuckton
Copy link
Contributor Author

rbuckton commented Jul 8, 2019

Other than catching a lot of other diagnostics changes from a different commit, it seems to have addressed https://github.com/microsoft/TypeScript/pull/32244/files#diff-601ae163618e1a582913605ac0b1b7c1R107 from the generator types user test.

@rbuckton
Copy link
Contributor Author

@weswigham: Can you take a look?

@rbuckton rbuckton merged commit 17762c4 into master Jul 15, 2019
@jakebailey jakebailey deleted the generatorReturnTypeFallback branch November 7, 2022 17:34
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants