mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05: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:
committed by
GitHub
parent
6b493f2048
commit
1814e2a5c4
@@ -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;
|
||||
|
||||
23
tests/cases/fourslash/jsdocDeprecated_suggestion5.ts
Normal file
23
tests/cases/fourslash/jsdocDeprecated_suggestion5.ts
Normal file
@@ -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