Skip to content

Commit

Permalink
merge helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingwl committed Jul 22, 2020
1 parent a593fd0 commit 58f6f3d
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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((<Decorator | CallExpression | NewExpression>node).expression);
case SyntaxKind.TaggedTemplateExpression:
return getDeprecatedSuggestionNode(node.tag);
return getDeprecatedSuggestionNode((<TaggedTemplateExpression>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((<JsxOpeningLikeElement>node).tagName);
case SyntaxKind.ElementAccessExpression:
return (<ElementAccessExpression>node).argumentExpression;
case SyntaxKind.PropertyAccessExpression:
Expand Down

0 comments on commit 58f6f3d

Please sign in to comment.