Skip to content

「Bug」multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred #34732

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

Closed
ghost opened this issue Oct 25, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 25, 2019

According to the #21496 PR, there should be string & number expected results

type Bar<T> = T extends { a: (x: infer U) => void; b: (x: infer U) => void } ? U : never;
type T20 = Bar<{ a: (x: string) => void; b: (x: string) => void }>; // string
type T21 = Bar<{ a: (x: string) => void; b: (x: number) => void }>; // string & number

However, under ts version 3.6.4, the results are not as expected

QQ20191025-163119.png

QQ20191025-163934.png

@ghost ghost changed the title multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred 「Bug」multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred Oct 26, 2019
@fatcerberus
Copy link

string & number is an empty intersection (there is no value that can satisfy that type) and now collapses to never eagerly per #31838. It still collapsed to never before that PR, but was lazy and didn't happen until the type was used in a distributive context. Now (as of TS 3.6) it happens immediately.

@IllusionMH
Copy link
Contributor

IllusionMH commented Oct 29, 2019

Not a duplicate but related to #34684. This is expected behavior as described above

@ghost ghost closed this as completed Oct 30, 2019
This issue was closed.
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

No branches or pull requests

2 participants