Don't eagerly get apparent type of spread expression contextual type (#44002)

* Don't get apparent type of contextual type for spread expressions

* Add regression test
This commit is contained in:
Anders Hejlsberg
2021-05-07 15:44:17 -07:00
committed by GitHub
parent cb9cd898d1
commit 42f0cf6ffc
5 changed files with 157 additions and 1 deletions

View File

@@ -25536,7 +25536,7 @@ namespace ts {
case SyntaxKind.ShorthandPropertyAssignment:
return getContextualTypeForObjectLiteralElement(<PropertyAssignment | ShorthandPropertyAssignment>parent, contextFlags);
case SyntaxKind.SpreadAssignment:
return getApparentTypeOfContextualType(parent.parent as ObjectLiteralExpression, contextFlags);
return getContextualType(parent.parent as ObjectLiteralExpression, contextFlags);
case SyntaxKind.ArrayLiteralExpression: {
const arrayLiteral = <ArrayLiteralExpression>parent;
const type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);