Undo 'any' inference propagation#22736
Conversation
Removing this only changes one test slightly, and fixes JQuery types, which rely on the old method of inference.
|
Note that inference pre-#22197 was not right; for |
ahejlsberg
left a comment
There was a problem hiding this comment.
The any propagation code was added primarily to propagate wildcards (one of our sentinel any types). It appears that other changes in the conditional type logic has shrouded tests that previously depended on it, but I wouldn't want to completely get rid of it. I suggest you change to only propagate wildcards.
| if (!couldContainTypeVariables(target)) { | ||
| return; | ||
| } | ||
| if (source.flags & TypeFlags.Any) { |
There was a problem hiding this comment.
Change this to source === wildcardType and keep everything else unchanged.
|
Sounds good. From discussion with @weswigham, it sounds like we need to revisit this after 2.8 to handle variance better. |
* Undo 'any' inference propagation Removing this only changes one test slightly, and fixes JQuery types, which rely on the old method of inference. * Add jquery regression test and update baselines * Restore any inference propagation to wildcard only
|
This is now in 2.8 as well. |
Fixes #22362
#22197 introduced a change to inference where
anyas the source caused an inference fromanyto be added for all type parameters in the target. It's not clear that this "deep-any" behaviour is correct or useful.Specifically, this change breaks inference in JQuery while changing only one other test; an inferred property deep inside mappedTypeRecursiveInference. There, when inferring from XMLHttpRequest to PartialDeep, one property has type
anywhich would otherwise have type{}.In this PR, I just undid the change and added a test that @Andy-MS simplified from the real jquery.d.ts on DefinitelyTyped.