Skip to content

Fixed an issue with self-referential awaited union#49677

Merged
jakebailey merged 2 commits intomicrosoft:mainfrom
Andarist:fix/self-referential-awaited-against-generic
Jun 29, 2022
Merged

Fixed an issue with self-referential awaited union#49677
jakebailey merged 2 commits intomicrosoft:mainfrom
Andarist:fix/self-referential-awaited-against-generic

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

fixes #49646

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 24, 2022
Comment on lines +16 to +18
!!! error TS2322: Type 'SimpleType' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'SimpleType'.
!!! related TS6502 tests/cases/compiler/genericFunctionAgainstUnresolvableSelfReferencingAwaitedUnion.ts:3:20: The expected type comes from the return type of this signature.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakebailey
Copy link
Copy Markdown
Member

jakebailey commented Jun 29, 2022

Thanks for sending this; do you mind adding the test from #49723 too? Doing so will file the error message this PR adds, in my testing.

LGTM, otherwise.

@jakebailey
Copy link
Copy Markdown
Member

Thanks for adding the test; did you intend to delete the test from #49646?

export async function myFunction(param: T1) {
const awaited = await param
~~~~~~~~~~~
!!! error TS1062: Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakebailey I've added the test case from your issue - note that the reported error is slightly different from the other one but I assume that's expected (since the other one was specific to generic functions and this ain't one)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct.

@jakebailey
Copy link
Copy Markdown
Member

Oh, nevermind, it's just one file now.

@jakebailey jakebailey merged commit bd11ce2 into microsoft:main Jun 29, 2022
@Andarist Andarist deleted the fix/self-referential-awaited-against-generic branch June 29, 2022 21:40
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite recursion with generics and recursive Promise type

3 participants