Repository navigation
Do not consider binding patterns in contextual types for return type … - #39081
Wesley Wigham (weswigham) merged 1 commit into
Conversation
…inference where all the signature type parameters have defaults
commented
Jun 15, 2020
|
TypeScript Bot (@typescript-bot) user test this |
|
Heya Wesley Wigham (@weswigham), I've started to run the parallelized Definitely Typed test suite on this PR at a42e1ae. You can monitor the build here. |
|
Heya Wesley Wigham (@weswigham), I've started to run the perf test suite on this PR at a42e1ae. You can monitor the build here. Update: The results are in! |
|
Heya Wesley Wigham (@weswigham), I've started to run the parallelized community code test suite on this PR at a42e1ae. You can monitor the build here. |
|
Heya Wesley Wigham (@weswigham), I've started to run the extended test suite on this PR at a42e1ae. You can monitor the build here. |
commented
Jun 15, 2020
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
commented
Jun 15, 2020
|
User baselines are fine, as are rwc baselines. DT has one new failure, in const { id } = useParams();
export function useParams<Params extends { [K in keyof Params]?: string }>(): {[K in keyof Params]: Params[K] extends never ? string : Params[K]}; |
commented
Jun 15, 2020
|
Wesley Wigham (@weswigham) Here they are:Comparison Report - master..39081
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
commented
Jun 15, 2020
|
And perf is fine, not that I expected a diff. |
commented
Jun 24, 2020
|
Anders Hejlsberg (@ahejlsberg) wanna take a look at this? I know we've discussed how we handle binding pattern contextual types (and how odd they are) before. |
commented
Jun 24, 2020
|
BTW, looks like this would fix #32003, yes? |
commented
Jun 24, 2020
|
easy way to find out: TypeScript Bot (@typescript-bot) pack this |
|
Heya Wesley Wigham (@weswigham), I've started to run the tarball bundle task on this PR at a42e1ae. You can monitor the build here. |
commented
Jun 24, 2020
|
sigh man that merge commit got deleted the moment I deleted the branch. Anyways, from local testing: Yep, this fixes #32003. So long as the type parameter has a default, we'll prefer it in return type inference over a binding pattern. |
…inference where all the signature type parameters have defaults
Fixes #38969
So, when I was looking into #38969 I was tempted to call it working as intended, as it's a logical fallout of current rules for inference and contextual typing; but that felt really unsatisfying, as we know that binding pattern shapes are rather poor inference targets. I went through a few iterations, but here have settled on the simple addition of a new heuristic for inference: If all type parameters the signature we're inferring to have defaults, then we disable the usage of binding patterns in contextual type lookup, which, in turn, allows us to fallback to using those defaults, over those binding pattern types.