mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Rename SyntaxKind.JSDocComment -> JSDoc (#44416)
* Rename SyntaxKind.JSDocComment -> JSDoc Early on, I made the mistake of using the syntax kind JSDocComment for the type JSDoc. This arose because I hadn't decided on the terminology of "jsdoc" for the C-style comment that is attached to a declaration. "comment" for the text that follows a tag. By the time I settled on those terms consistently, a version had already shipped with `interface JSDoc` having `SyntaxKind.JSDocComment`. However, there is now a `type JSDocComment` that represents the possible contents of the comment text (strings and various kinds of `@link`), so it's doubly confusing that this type has a union of four kinds instead of SyntaxKind.JSDocComment. Although this is a public API break, I don't think it's hard to recover from, and the JSDoc API has accessors for individual tag types, so I suspect few people refer directly to SyntaxKind.JSDocComment. * Add deprecate JSDocComment alias to JSDoc For backward compatibility * Make JSDoc an alias of JSDocComment Improves output of JSDocParsing tests without having to make its code smarter. * update API baselines
This commit is contained in:
@@ -1831,7 +1831,7 @@ namespace ts {
|
||||
// - parameters are only in the scope of function body
|
||||
// This restriction does not apply to JSDoc comment types because they are parented
|
||||
// at a higher level than type parameters would normally be
|
||||
if (meaning & result.flags & SymbolFlags.Type && lastLocation.kind !== SyntaxKind.JSDocComment) {
|
||||
if (meaning & result.flags & SymbolFlags.Type && lastLocation.kind !== SyntaxKind.JSDoc) {
|
||||
useResult = result.flags & SymbolFlags.TypeParameter
|
||||
// type parameters are visible in parameter list, return type and type parameter list
|
||||
? lastLocation === (location as FunctionLikeDeclaration).type ||
|
||||
@@ -9963,7 +9963,7 @@ namespace ts {
|
||||
node = paramSymbol.valueDeclaration!;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.JSDocComment: {
|
||||
case SyntaxKind.JSDoc: {
|
||||
const outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
|
||||
return (node as JSDoc).tags
|
||||
? appendTypeParameters(outerTypeParameters, flatMap((node as JSDoc).tags, t => isJSDocTemplateTag(t) ? t.typeParameters : undefined))
|
||||
@@ -13660,7 +13660,7 @@ namespace ts {
|
||||
function getConditionalFlowTypeOfType(type: Type, node: Node) {
|
||||
let constraints: Type[] | undefined;
|
||||
let covariant = true;
|
||||
while (node && !isStatement(node) && node.kind !== SyntaxKind.JSDocComment) {
|
||||
while (node && !isStatement(node) && node.kind !== SyntaxKind.JSDoc) {
|
||||
const parent = node.parent;
|
||||
// only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but
|
||||
// often get used in indexed accesses where they behave sortof invariantly, but our checking is lax
|
||||
|
||||
@@ -1596,7 +1596,7 @@ namespace ts {
|
||||
return emitRestOrJSDocVariadicType(node as RestTypeNode | JSDocVariadicType);
|
||||
case SyntaxKind.JSDocNamepathType:
|
||||
return;
|
||||
case SyntaxKind.JSDocComment:
|
||||
case SyntaxKind.JSDoc:
|
||||
return emitJSDoc(node as JSDoc);
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
return emitJSDocTypeLiteral(node as JSDocTypeLiteral);
|
||||
|
||||
@@ -4740,7 +4740,7 @@ namespace ts {
|
||||
|
||||
// @api
|
||||
function createJSDocComment(comment?: string | NodeArray<JSDocComment> | undefined, tags?: readonly JSDocTag[] | undefined) {
|
||||
const node = createBaseNode<JSDoc>(SyntaxKind.JSDocComment);
|
||||
const node = createBaseNode<JSDoc>(SyntaxKind.JSDoc);
|
||||
node.comment = comment;
|
||||
node.tags = asNodeArray(tags);
|
||||
return node;
|
||||
|
||||
@@ -836,7 +836,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isJSDoc(node: Node): node is JSDoc {
|
||||
return node.kind === SyntaxKind.JSDocComment;
|
||||
return node.kind === SyntaxKind.JSDoc;
|
||||
}
|
||||
|
||||
export function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral {
|
||||
|
||||
@@ -495,7 +495,7 @@ namespace ts {
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
return visitNodes(cbNode, cbNodes, (node as JSDocFunctionType).parameters) ||
|
||||
visitNode(cbNode, (node as JSDocFunctionType).type);
|
||||
case SyntaxKind.JSDocComment:
|
||||
case SyntaxKind.JSDoc:
|
||||
return (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined))
|
||||
|| visitNodes(cbNode, cbNodes, (node as JSDoc).tags);
|
||||
case SyntaxKind.JSDocSeeTag:
|
||||
|
||||
@@ -378,6 +378,7 @@ namespace ts {
|
||||
JSDocFunctionType,
|
||||
JSDocVariadicType,
|
||||
JSDocNamepathType, // https://jsdoc.app/about-namepaths.html
|
||||
/** @deprecated Use SyntaxKind.JSDoc */
|
||||
JSDocComment,
|
||||
JSDocText,
|
||||
JSDocTypeLiteral,
|
||||
@@ -455,6 +456,7 @@ namespace ts {
|
||||
LastJSDocTagNode = JSDocPropertyTag,
|
||||
/* @internal */ FirstContextualKeyword = AbstractKeyword,
|
||||
/* @internal */ LastContextualKeyword = OfKeyword,
|
||||
JSDoc = JSDocComment,
|
||||
}
|
||||
|
||||
export type TriviaSyntaxKind =
|
||||
@@ -3256,7 +3258,7 @@ namespace ts {
|
||||
;
|
||||
|
||||
export interface JSDoc extends Node {
|
||||
readonly kind: SyntaxKind.JSDocComment;
|
||||
readonly kind: SyntaxKind.JSDoc;
|
||||
readonly parent: HasJSDoc;
|
||||
readonly tags?: NodeArray<JSDocTag>;
|
||||
readonly comment?: string | NodeArray<JSDocComment>;
|
||||
|
||||
@@ -4610,7 +4610,7 @@ namespace ts {
|
||||
|
||||
/** template tags are only available when a typedef isn't already using them */
|
||||
function isNonTypeAliasTemplate(tag: JSDocTag): tag is JSDocTemplateTag {
|
||||
return isJSDocTemplateTag(tag) && !(tag.parent.kind === SyntaxKind.JSDocComment && tag.parent.tags!.some(isJSDocTypeAlias));
|
||||
return isJSDocTemplateTag(tag) && !(tag.parent.kind === SyntaxKind.JSDoc && tag.parent.tags!.some(isJSDocTypeAlias));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -926,7 +926,7 @@ namespace ts {
|
||||
return emptyArray;
|
||||
}
|
||||
if (isJSDocTypeAlias(node)) {
|
||||
Debug.assert(node.parent.kind === SyntaxKind.JSDocComment);
|
||||
Debug.assert(node.parent.kind === SyntaxKind.JSDoc);
|
||||
return flatMap(node.parent.tags, tag => isJSDocTemplateTag(tag) ? tag.typeParameters : undefined);
|
||||
}
|
||||
if (node.typeParameters) {
|
||||
@@ -1912,7 +1912,7 @@ namespace ts {
|
||||
|
||||
/** True if node is of a kind that may contain comment text. */
|
||||
export function isJSDocCommentContainingNode(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.JSDocComment
|
||||
return node.kind === SyntaxKind.JSDoc
|
||||
|| node.kind === SyntaxKind.JSDocNamepathType
|
||||
|| node.kind === SyntaxKind.JSDocText
|
||||
|| isJSDocLinkLike(node)
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 54,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 674,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 15,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 21,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 8,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 9,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 66,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 44,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 49,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 23,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 739,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 55,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 5,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 27,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 61,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 91,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 27,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 20,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 34,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 59,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 61,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 66,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 34,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 46,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 23,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 29,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 54,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 30,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 24,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 26,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 27,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 27,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 28,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 60,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 7,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 60,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 56,
|
||||
"flags": "JSDoc",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 27,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"kind": "JSDoc",
|
||||
"pos": 0,
|
||||
"end": 102,
|
||||
"flags": "JSDoc",
|
||||
|
||||
+3
-1
@@ -424,6 +424,7 @@ declare namespace ts {
|
||||
JSDocFunctionType = 316,
|
||||
JSDocVariadicType = 317,
|
||||
JSDocNamepathType = 318,
|
||||
/** @deprecated Use SyntaxKind.JSDoc */
|
||||
JSDocComment = 319,
|
||||
JSDocText = 320,
|
||||
JSDocTypeLiteral = 321,
|
||||
@@ -491,6 +492,7 @@ declare namespace ts {
|
||||
LastJSDocNode = 346,
|
||||
FirstJSDocTagNode = 326,
|
||||
LastJSDocTagNode = 346,
|
||||
JSDoc = 319
|
||||
}
|
||||
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
|
||||
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
@@ -1820,7 +1822,7 @@ declare namespace ts {
|
||||
}
|
||||
export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
|
||||
export interface JSDoc extends Node {
|
||||
readonly kind: SyntaxKind.JSDocComment;
|
||||
readonly kind: SyntaxKind.JSDoc;
|
||||
readonly parent: HasJSDoc;
|
||||
readonly tags?: NodeArray<JSDocTag>;
|
||||
readonly comment?: string | NodeArray<JSDocComment>;
|
||||
|
||||
+3
-1
@@ -424,6 +424,7 @@ declare namespace ts {
|
||||
JSDocFunctionType = 316,
|
||||
JSDocVariadicType = 317,
|
||||
JSDocNamepathType = 318,
|
||||
/** @deprecated Use SyntaxKind.JSDoc */
|
||||
JSDocComment = 319,
|
||||
JSDocText = 320,
|
||||
JSDocTypeLiteral = 321,
|
||||
@@ -491,6 +492,7 @@ declare namespace ts {
|
||||
LastJSDocNode = 346,
|
||||
FirstJSDocTagNode = 326,
|
||||
LastJSDocTagNode = 346,
|
||||
JSDoc = 319
|
||||
}
|
||||
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
|
||||
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
@@ -1820,7 +1822,7 @@ declare namespace ts {
|
||||
}
|
||||
export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
|
||||
export interface JSDoc extends Node {
|
||||
readonly kind: SyntaxKind.JSDocComment;
|
||||
readonly kind: SyntaxKind.JSDoc;
|
||||
readonly parent: HasJSDoc;
|
||||
readonly tags?: NodeArray<JSDocTag>;
|
||||
readonly comment?: string | NodeArray<JSDocComment>;
|
||||
|
||||
Reference in New Issue
Block a user