From 58f6f3daf27d612ec12a45d3bf02c2bd161f7285 Mon Sep 17 00:00:00 2001 From: kingwl Date: Wed, 22 Jul 2020 19:21:12 +0800 Subject: [PATCH] merge helper function --- src/compiler/checker.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7265057fa8e63..8c7bf1f6b20c0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -27536,30 +27536,23 @@ namespace ts { function checkDeprecatedSignature(signature: Signature, node: CallLikeExpression) { if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) { - const suggestionNode = getSignatureSuggestionNode(node); + const suggestionNode = getDeprecatedSuggestionNode(node); errorOrSuggestion(/*isError*/ false, suggestionNode, Diagnostics._0_is_deprecated, signatureToString(signature)); } } - function getSignatureSuggestionNode(node: CallLikeExpression): Node { + function getDeprecatedSuggestionNode(node: Node): Node { + node = skipParentheses(node); switch (node.kind) { case SyntaxKind.CallExpression: case SyntaxKind.Decorator: case SyntaxKind.NewExpression: - return getDeprecatedSuggestionNode(node.expression); + return getDeprecatedSuggestionNode((node).expression); case SyntaxKind.TaggedTemplateExpression: - return getDeprecatedSuggestionNode(node.tag); + return getDeprecatedSuggestionNode((node).tag); case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxSelfClosingElement: - return getDeprecatedSuggestionNode(node.tagName); - default: - return Debug.assertNever(node); - } - } - - function getDeprecatedSuggestionNode(node: Node): Node { - node = skipParentheses(node); - switch (node.kind) { + return getDeprecatedSuggestionNode((node).tagName); case SyntaxKind.ElementAccessExpression: return (node).argumentExpression; case SyntaxKind.PropertyAccessExpression: