Revert "Stop looking at binding patterns for type argument inference" (#46013)

* Revert "Stop looking at binding patterns for type argument inference (#45719)"

This reverts commit be618b1446.

* Update error baseline for moved lib file declaration
This commit is contained in:
Andrew Branch
2021-09-23 09:26:51 -07:00
committed by GitHub
parent efbce1099c
commit 039672332f
4 changed files with 26 additions and 18 deletions

View File

@@ -25445,8 +25445,7 @@ namespace ts {
if (result) {
return result;
}
if (!(contextFlags! & ContextFlags.SkipBindingPatterns) && isBindingPattern(declaration.name)) {
// This is less a contextual type and more an implied shape - in some cases, this may be undesirable
if (!(contextFlags! & ContextFlags.SkipBindingPatterns) && isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
}
}
@@ -28753,7 +28752,7 @@ namespace ts {
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
// return type of 'wrap'.
if (node.kind !== SyntaxKind.Decorator) {
const contextualType = getContextualType(node, ContextFlags.SkipBindingPatterns);
const contextualType = getContextualType(node, every(signature.typeParameters, p => !!getDefaultFromTypeParameter(p)) ? ContextFlags.SkipBindingPatterns : ContextFlags.None);
if (contextualType) {
// We clone the inference context to avoid disturbing a resolution in progress for an
// outer call expression. Effectively we just want a snapshot of whatever has been