Generic functions are never context sensitive (#37811)

* Functions with type parameters are never contextsensitive

* Add tests
This commit is contained in:
Anders Hejlsberg
2020-04-06 11:55:39 -07:00
committed by GitHub
parent eac073894b
commit 5a4024dd9d
5 changed files with 66 additions and 1 deletions

View File

@@ -14251,7 +14251,7 @@ namespace ts {
function hasContextSensitiveReturnExpression(node: FunctionLikeDeclaration) {
// TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
return !getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== SyntaxKind.Block && isContextSensitive(node.body);
return !node.typeParameters && !getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== SyntaxKind.Block && isContextSensitive(node.body);
}
function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration {