Consider all constituents of contextual return type when resolving type of 'yield'#56222
Conversation
|
My old PR that awaits review already fixes this issue (I just pushed out a test case that is being added here in this PR). It also shares all of the baseline changes that you have here. Would you mind re-reviewing that PR and comparing the used approaches? Maybe it would be also good to pull all the other test cases that I added there here to compare their results? |
The test in tests/cases/compiler/contextuallyTypeAsyncFunctionReturnTypeFromUnion.ts fails in my branch. It looks like your PR covers more cases, so I'll happily close this branch in favor of your PR. |
|
Closed in favor of #51196. |
This avoids an early-exit in
getIterationTypesOfIterablewhen the intended use is resolving the iteration types of a contextual return type of a generator function:The above code is an error currently as we drop the iteration types of the first constituent when the second fails.
For other uses we continue to preserve the early exit so that we correctly error for cases such as this:
Fixes #42439