FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Revert binding pattern inference changes, but only for tuples by andrewbranch · Pull Request #46009 · microsoft/TypeScript · GitHub

Revert binding pattern inference changes, but only for tuples - #46009

Closed
Andrew Branch (andrewbranch) wants to merge 1 commit into
microsoft:mainfrom
andrewbranch:bug/array-binding-pattern
Closed

Revert binding pattern inference changes, but only for tuples#46009
Andrew Branch (andrewbranch) wants to merge 1 commit into
microsoft:mainfrom
andrewbranch:bug/array-binding-pattern

Conversation

Copy link
Copy Markdown
Member

Partial revert of #45719—we now let an array binding pattern turn inference of an array into a tuple, which is really nice. I still think the behavior we were seeing for object binding patterns was undesirable, and #45846 supports that hypothesis since all the related errors were due to a tuple turning into an array.

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) user test this inline

TypeScript Bot (typescript-bot) commented Sep 22, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

Heya Andrew Branch (@andrewbranch), I've started to run the inline community code test suite on this PR at c3bcc4c. You can monitor the build here.

Update: The results are in!

Copy link
Copy Markdown
Contributor

Andrew Branch (@andrewbranch)
Great news! no new errors were found between main..refs/pull/46009/merge

Copy link
Copy Markdown
Member Author

We realized that

declare function f<T>(): T;
const [a, b, c] = f();

should really error, and this PR makes it legal (T is inferred as [any, any, any]). While it may be true that object binding patterns never contribute anything useful to type argument inference, it is not true that array binding patterns always contribute usefully to type argument inference. What we really want is for binding patterns to contribute contextual typing information to other inference sources, while never being allowed to stand on their own as inference sources. I’m going to close this and do a full revert of #45719 so we can investigate a more thorough solution in the future.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL