From c6a2e4576845ce08ef0cbb0cfcb80a5fd0008f89 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:42:00 -0700 Subject: [PATCH] Add @deprecated to tree walk (#43473) So various things don't crash. Fixes #43472 --- src/compiler/parser.ts | 1 + .../quickInfoInheritedLinkTag.baseline | 111 ++++++++++++++++++ .../fourslash/quickInfoInheritedLinkTag.ts | 15 +++ 3 files changed, 127 insertions(+) create mode 100644 tests/baselines/reference/quickInfoInheritedLinkTag.baseline create mode 100644 tests/cases/fourslash/quickInfoInheritedLinkTag.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1d42346123b..cdd63c9c947 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -551,6 +551,7 @@ namespace ts { case SyntaxKind.JSDocPrivateTag: case SyntaxKind.JSDocProtectedTag: case SyntaxKind.JSDocReadonlyTag: + case SyntaxKind.JSDocDeprecatedTag: return visitNode(cbNode, (node as JSDocTag).tagName) || (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray | undefined)); case SyntaxKind.PartiallyEmittedExpression: diff --git a/tests/baselines/reference/quickInfoInheritedLinkTag.baseline b/tests/baselines/reference/quickInfoInheritedLinkTag.baseline new file mode 100644 index 00000000000..52047ab8870 --- /dev/null +++ b/tests/baselines/reference/quickInfoInheritedLinkTag.baseline @@ -0,0 +1,111 @@ +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoInheritedLinkTag.ts", + "position": 258, + "name": "" + }, + "quickInfo": { + "kind": "method", + "kindModifiers": "deprecated", + "textSpan": { + "start": 257, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "C", + "kind": "className" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "m", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "documentation": [], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "Use ", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "PerspectiveCamera#setFocalLength .setFocalLength()", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + }, + { + "text": " and ", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "PerspectiveCamera#filmGauge .filmGauge", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + }, + { + "text": " instead.", + "kind": "text" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoInheritedLinkTag.ts b/tests/cases/fourslash/quickInfoInheritedLinkTag.ts new file mode 100644 index 00000000000..f1eb08d1327 --- /dev/null +++ b/tests/cases/fourslash/quickInfoInheritedLinkTag.ts @@ -0,0 +1,15 @@ +/// + +//// export class C { +//// /** +//// * @deprecated Use {@link PerspectiveCamera#setFocalLength .setFocalLength()} and {@link PerspectiveCamera#filmGauge .filmGauge} instead. +//// */ +//// m() { } +//// } +//// export class D extends C { +//// m() { } // crashes here +//// } +//// new C().m/**/ // and here (with a different thing trying to access undefined) + +verify.noErrors() +verify.baselineQuickInfo();