mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Mark @typedef as a type declaration (#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 #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.
This commit is contained in:
@@ -36107,16 +36107,19 @@ namespace ts {
|
||||
function isTypeDeclarationName(name: Node): boolean {
|
||||
return name.kind === SyntaxKind.Identifier &&
|
||||
isTypeDeclaration(name.parent) &&
|
||||
name.parent.name === name;
|
||||
getNameOfDeclaration(name.parent) === name;
|
||||
}
|
||||
|
||||
function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration | ImportClause | ImportSpecifier | ExportSpecifier {
|
||||
function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag | EnumDeclaration | ImportClause | ImportSpecifier | ExportSpecifier {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
case SyntaxKind.JSDocCallbackTag:
|
||||
case SyntaxKind.JSDocEnumTag:
|
||||
return true;
|
||||
case SyntaxKind.ImportClause:
|
||||
return (node as ImportClause).isTypeOnly;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @Filename: jsdocDeprecated_suggestion5.js
|
||||
//// /** @typedef {{ email: string, nickName?: string }} U2 */
|
||||
//// /** @type {U2} */
|
||||
//// const u2 = { email: "" }
|
||||
|
||||
//// /**
|
||||
//// * @callback K
|
||||
//// * @param {any} ctx
|
||||
//// * @return {void}
|
||||
//// */
|
||||
//// /** @type {K} */
|
||||
//// const cc = _k => {}
|
||||
|
||||
//// /** @enum {number} */
|
||||
//// const DOOM = { e: 1, m: 1 }
|
||||
//// /** @type {DOOM} */
|
||||
//// const kneeDeep = DOOM.e
|
||||
|
||||
verify.getSuggestionDiagnostics([])
|
||||
Reference in New Issue
Block a user