Skip to content

Fixed an issue with self-referential awaited union #49677

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

Conversation

Andarist
Copy link
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
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
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
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
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
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
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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