Skip to content

Commit 1814e2a

Browse files
authored
Mark @typedef as a type declaration (microsoft#39468)
* Mark @typedef as a type declaration This is only important right now for marking uses of deprecated tags due to the way that deprecated type references are computed. But I'm surprised it hasn't caused problems elsewhere. Fixes microsoft#39466 * Also mark @callback and @enum Requires making name lookup in isTypeDeclarationName smarter, but this is only used by services, so shouldn't be too performance sensitive.
1 parent 6b493f2 commit 1814e2a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36107,16 +36107,19 @@ namespace ts {
3610736107
function isTypeDeclarationName(name: Node): boolean {
3610836108
return name.kind === SyntaxKind.Identifier &&
3610936109
isTypeDeclaration(name.parent) &&
36110-
name.parent.name === name;
36110+
getNameOfDeclaration(name.parent) === name;
3611136111
}
3611236112

36113-
function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration | ImportClause | ImportSpecifier | ExportSpecifier {
36113+
function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag | EnumDeclaration | ImportClause | ImportSpecifier | ExportSpecifier {
3611436114
switch (node.kind) {
3611536115
case SyntaxKind.TypeParameter:
3611636116
case SyntaxKind.ClassDeclaration:
3611736117
case SyntaxKind.InterfaceDeclaration:
3611836118
case SyntaxKind.TypeAliasDeclaration:
3611936119
case SyntaxKind.EnumDeclaration:
36120+
case SyntaxKind.JSDocTypedefTag:
36121+
case SyntaxKind.JSDocCallbackTag:
36122+
case SyntaxKind.JSDocEnumTag:
3612036123
return true;
3612136124
case SyntaxKind.ImportClause:
3612236125
return (node as ImportClause).isTypeOnly;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// @checkJs: true
4+
// @allowJs: true
5+
// @Filename: jsdocDeprecated_suggestion5.js
6+
//// /** @typedef {{ email: string, nickName?: string }} U2 */
7+
//// /** @type {U2} */
8+
//// const u2 = { email: "" }
9+
10+
//// /**
11+
//// * @callback K
12+
//// * @param {any} ctx
13+
//// * @return {void}
14+
//// */
15+
//// /** @type {K} */
16+
//// const cc = _k => {}
17+
18+
//// /** @enum {number} */
19+
//// const DOOM = { e: 1, m: 1 }
20+
//// /** @type {DOOM} */
21+
//// const kneeDeep = DOOM.e
22+
23+
verify.getSuggestionDiagnostics([])

0 commit comments

Comments
 (0)