Skip to content

Better detect when typical nondistributive conditionals need to be deferred... #42248

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

weswigham
Copy link
Member

…by unwrapping their check and extends types. We use a heuristic for conditional type deferral - our isGenericObjectType and isGenericIndexType helpers. Unfortunately, these aren't tuned to check for nested generics within types, such as tuples, as we often see for non-distributive conditional types. Rather than changing those functions (where are used elsewhere), instead I detect when a conditional type has a typical non-distributive shape (one-tuple extends one-tuple), and immediately unwrap the tuple types - this both saves us a bit of work, and allows the deferral checks to operate like we want.

Fixes #39992

…fered by unwrapping their check and extends types
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jan 7, 2021
@weswigham weswigham merged commit c3dd845 into microsoft:master Jan 12, 2021
@weswigham weswigham deleted the conditional-type-better-deferral-detection branch January 12, 2021 20:59
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jan 13, 2021
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jan 13, 2021
Zzzen pushed a commit to Zzzen/TypeScript that referenced this pull request Jan 16, 2021
kaznovac pushed a commit to kaznovac/DefinitelyTyped that referenced this pull request Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
3 participants