Skip to content

Commit 3696f94

Browse files
committed
introduce JSDocIgnoreTag
1 parent 380d740 commit 3696f94

File tree

8 files changed

+77
-37
lines changed

8 files changed

+77
-37
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ import {
303303
getExternalModuleRequireArgument,
304304
getFirstConstructorWithBody,
305305
getFirstIdentifier,
306-
getFirstJSDocTag,
307306
getFunctionFlags,
308307
getHostSignatureFromJSDoc,
309308
getIdentifierGeneratedImportReference,
@@ -317,6 +316,7 @@ import {
317316
getJSDocDeprecatedTag,
318317
getJSDocEnumTag,
319318
getJSDocHost,
319+
getJSDocIgnoreTag,
320320
getJSDocOverloadTags,
321321
getJSDocParameterTags,
322322
getJSDocRoot,
@@ -806,7 +806,6 @@ import {
806806
JSDocPublicTag,
807807
JSDocSatisfiesTag,
808808
JSDocSignature,
809-
JSDocTag,
810809
JSDocTemplateTag,
811810
JSDocThisTag,
812811
JSDocTypeAssertion,
@@ -34492,7 +34491,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3449234491
*/
3449334492
function isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode | QualifiedName, type: Type, property: Symbol): boolean {
3449434493
return isPropertyAccessible(node, node.kind === SyntaxKind.PropertyAccessExpression && node.expression.kind === SyntaxKind.SuperKeyword, /*isWrite*/ false, type, property)
34495-
&& (!property.valueDeclaration || !getFirstJSDocTag(property.valueDeclaration, (t): t is JSDocTag => t.kind === SyntaxKind.JSDocTag && t.tagName.escapedText === "ignore"));
34494+
&& (!property.declarations || some(property.declarations, decl => !getJSDocIgnoreTag(decl)));
3449634495
// Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context.
3449734496
}
3449834497

src/compiler/emitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
18461846
return emitJSDocHeritageTag(node as JSDocImplementsTag | JSDocAugmentsTag);
18471847
case SyntaxKind.JSDocAuthorTag:
18481848
case SyntaxKind.JSDocDeprecatedTag:
1849+
case SyntaxKind.JSDocIgnoreTag:
18491850
return;
18501851
// SyntaxKind.JSDocClassTag (see JSDocTag, above)
18511852
case SyntaxKind.JSDocPublicTag:

src/compiler/factory/nodeFactory.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ import {
225225
JSDocDeprecatedTag,
226226
JSDocEnumTag,
227227
JSDocFunctionType,
228+
JSDocIgnoreTag,
228229
JSDocImplementsTag,
229230
JSDocImportTag,
230231
JSDocLink,
@@ -938,6 +939,12 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
938939
get updateJSDocDeprecatedTag() {
939940
return getJSDocSimpleTagUpdateFunction<JSDocDeprecatedTag>(SyntaxKind.JSDocDeprecatedTag);
940941
},
942+
get createJSDocIgnoreTag() {
943+
return getJSDocSimpleTagCreateFunction<JSDocIgnoreTag>(SyntaxKind.JSDocIgnoreTag);
944+
},
945+
get updateJSDocIgnoreTag() {
946+
return getJSDocSimpleTagUpdateFunction<JSDocIgnoreTag>(SyntaxKind.JSDocIgnoreTag);
947+
},
941948
get createJSDocThrowsTag() {
942949
return getJSDocTypeLikeTagCreateFunction<JSDocThrowsTag>(SyntaxKind.JSDocThrowsTag);
943950
},
@@ -5448,6 +5455,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
54485455
// createJSDocProtectedTag
54495456
// createJSDocReadonlyTag
54505457
// createJSDocDeprecatedTag
5458+
// createJSDocIgnoreTag
54515459
function createJSDocSimpleTagWorker<T extends JSDocTag>(kind: T["kind"], tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>) {
54525460
const node = createBaseJSDocTag<T>(kind, tagName ?? createIdentifier(getDefaultTagNameForKind(kind)), comment);
54535461
return node;
@@ -5461,6 +5469,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
54615469
// updateJSDocProtectedTag
54625470
// updateJSDocReadonlyTag
54635471
// updateJSDocDeprecatedTag
5472+
// updateJSDocIgnoreTag
54645473
function updateJSDocSimpleTagWorker<T extends JSDocTag>(kind: T["kind"], node: T, tagName: Identifier = getDefaultTagName(node), comment: string | NodeArray<JSDocComment> | undefined) {
54655474
return node.tagName !== tagName
54665475
|| node.comment !== comment

src/compiler/factory/nodeTests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import {
9090
JSDocDeprecatedTag,
9191
JSDocEnumTag,
9292
JSDocFunctionType,
93+
JSDocIgnoreTag,
9394
JSDocImplementsTag,
9495
JSDocImportTag,
9596
JSDocLink,
@@ -1137,6 +1138,10 @@ export function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag {
11371138
return node.kind === SyntaxKind.JSDocDeprecatedTag;
11381139
}
11391140

1141+
export function isJSDocIgnoreTag(node: Node): node is JSDocIgnoreTag {
1142+
return node.kind === SyntaxKind.JSDocIgnoreTag;
1143+
}
1144+
11401145
export function isJSDocSeeTag(node: Node): node is JSDocSeeTag {
11411146
return node.kind === SyntaxKind.JSDocSeeTag;
11421147
}

src/compiler/parser.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ import {
176176
JSDocDeprecatedTag,
177177
JSDocEnumTag,
178178
JSDocFunctionType,
179+
JSDocIgnoreTag,
179180
JSDocImplementsTag,
180181
JSDocImportTag,
181182
JSDocLink,
@@ -1129,6 +1130,7 @@ const forEachChildTable: ForEachChildTable = {
11291130
[SyntaxKind.JSDocProtectedTag]: forEachChildInJSDocTag,
11301131
[SyntaxKind.JSDocReadonlyTag]: forEachChildInJSDocTag,
11311132
[SyntaxKind.JSDocDeprecatedTag]: forEachChildInJSDocTag,
1133+
[SyntaxKind.JSDocIgnoreTag]: forEachChildInJSDocTag,
11321134
[SyntaxKind.JSDocOverrideTag]: forEachChildInJSDocTag,
11331135
[SyntaxKind.JSDocImportTag]: forEachChildInJSDocImportTag,
11341136
[SyntaxKind.PartiallyEmittedExpression]: forEachChildInPartiallyEmittedExpression,
@@ -1215,7 +1217,7 @@ function forEachChildInJSDocLinkCodeOrPlain<T>(node: JSDocLink | JSDocLinkCode |
12151217
return visitNode(cbNode, node.name);
12161218
}
12171219

1218-
function forEachChildInJSDocTag<T>(node: JSDocUnknownTag | JSDocClassTag | JSDocPublicTag | JSDocPrivateTag | JSDocProtectedTag | JSDocReadonlyTag | JSDocDeprecatedTag | JSDocOverrideTag, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
1220+
function forEachChildInJSDocTag<T>(node: JSDocUnknownTag | JSDocClassTag | JSDocPublicTag | JSDocPrivateTag | JSDocProtectedTag | JSDocReadonlyTag | JSDocDeprecatedTag | JSDocIgnoreTag | JSDocOverrideTag, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
12191221
return visitNode(cbNode, node.tagName)
12201222
|| (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
12211223
}
@@ -9080,6 +9082,9 @@ namespace Parser {
90809082
hasDeprecatedTag = true;
90819083
tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText);
90829084
break;
9085+
case "ignore":
9086+
tag = parseSimpleTag(start, factory.createJSDocIgnoreTag, tagName, margin, indentText);
9087+
break;
90839088
case "this":
90849089
tag = parseThisTag(start, tagName, margin, indentText);
90859090
break;

src/compiler/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ export const enum SyntaxKind {
419419
JSDocImplementsTag,
420420
JSDocAuthorTag,
421421
JSDocDeprecatedTag,
422+
JSDocIgnoreTag,
422423
JSDocClassTag,
423424
JSDocPublicTag,
424425
JSDocPrivateTag,
@@ -1046,6 +1047,7 @@ export type ForEachChildNodes =
10461047
| JSDocProtectedTag
10471048
| JSDocReadonlyTag
10481049
| JSDocDeprecatedTag
1050+
| JSDocIgnoreTag
10491051
| JSDocThrowsTag
10501052
| JSDocOverrideTag
10511053
| JSDocSatisfiesTag
@@ -3986,6 +3988,10 @@ export interface JSDocDeprecatedTag extends JSDocTag {
39863988
kind: SyntaxKind.JSDocDeprecatedTag;
39873989
}
39883990

3991+
export interface JSDocIgnoreTag extends JSDocTag {
3992+
kind: SyntaxKind.JSDocIgnoreTag;
3993+
}
3994+
39893995
export interface JSDocClassTag extends JSDocTag {
39903996
readonly kind: SyntaxKind.JSDocClassTag;
39913997
}
@@ -9042,6 +9048,8 @@ export interface NodeFactory {
90429048
updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocComment> | undefined): JSDocUnknownTag;
90439049
createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
90449050
updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
9051+
createJSDocIgnoreTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocIgnoreTag;
9052+
updateJSDocIgnoreTag(node: JSDocIgnoreTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocIgnoreTag;
90459053
createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
90469054
updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
90479055
createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment>): JSDocThrowsTag;

src/compiler/utilitiesPublic.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ import {
140140
isJSDocDeprecatedTag,
141141
isJSDocEnumTag,
142142
isJSDocFunctionType,
143+
isJSDocIgnoreTag,
143144
isJSDocImplementsTag,
144145
isJSDocOverloadTag,
145146
isJSDocOverrideTag,
@@ -183,6 +184,7 @@ import {
183184
JSDocContainer,
184185
JSDocDeprecatedTag,
185186
JSDocEnumTag,
187+
JSDocIgnoreTag,
186188
JSDocImplementsTag,
187189
JSDocLink,
188190
JSDocLinkCode,
@@ -1161,6 +1163,11 @@ export function getJSDocDeprecatedTagNoCache(node: Node): JSDocDeprecatedTag | u
11611163
return getFirstJSDocTag(node, isJSDocDeprecatedTag, /*noCache*/ true);
11621164
}
11631165

1166+
/** Gets the JSDoc ignore tag for the node if present */
1167+
export function getJSDocIgnoreTag(node: Node): JSDocIgnoreTag | undefined {
1168+
return getFirstJSDocTag(node, isJSDocIgnoreTag);
1169+
}
1170+
11641171
/** Gets the JSDoc enum tag for the node if present */
11651172
export function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined {
11661173
return getFirstJSDocTag(node, isJSDocEnumTag);
@@ -1260,11 +1267,8 @@ export function getJSDocTags(node: Node): readonly JSDocTag[] {
12601267
return getJSDocTagsWorker(node, /*noCache*/ false);
12611268
}
12621269

1263-
/**
1264-
* @internal
1265-
* Get the first JSDoc tag of a specified kind, or undefined if not present.
1266-
*/
1267-
export function getFirstJSDocTag<T extends JSDocTag>(node: Node, predicate: (tag: JSDocTag) => tag is T, noCache?: boolean): T | undefined {
1270+
/** Get the first JSDoc tag of a specified kind, or undefined if not present. */
1271+
function getFirstJSDocTag<T extends JSDocTag>(node: Node, predicate: (tag: JSDocTag) => tag is T, noCache?: boolean): T | undefined {
12681272
return find(getJSDocTagsWorker(node, noCache), predicate);
12691273
}
12701274

tests/baselines/reference/api/typescript.d.ts

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3960,32 +3960,33 @@ declare namespace ts {
39603960
JSDocImplementsTag = 329,
39613961
JSDocAuthorTag = 330,
39623962
JSDocDeprecatedTag = 331,
3963-
JSDocClassTag = 332,
3964-
JSDocPublicTag = 333,
3965-
JSDocPrivateTag = 334,
3966-
JSDocProtectedTag = 335,
3967-
JSDocReadonlyTag = 336,
3968-
JSDocOverrideTag = 337,
3969-
JSDocCallbackTag = 338,
3970-
JSDocOverloadTag = 339,
3971-
JSDocEnumTag = 340,
3972-
JSDocParameterTag = 341,
3973-
JSDocReturnTag = 342,
3974-
JSDocThisTag = 343,
3975-
JSDocTypeTag = 344,
3976-
JSDocTemplateTag = 345,
3977-
JSDocTypedefTag = 346,
3978-
JSDocSeeTag = 347,
3979-
JSDocPropertyTag = 348,
3980-
JSDocThrowsTag = 349,
3981-
JSDocSatisfiesTag = 350,
3982-
JSDocImportTag = 351,
3983-
SyntaxList = 352,
3984-
NotEmittedStatement = 353,
3985-
PartiallyEmittedExpression = 354,
3986-
CommaListExpression = 355,
3987-
SyntheticReferenceExpression = 356,
3988-
Count = 357,
3963+
JSDocIgnoreTag = 332,
3964+
JSDocClassTag = 333,
3965+
JSDocPublicTag = 334,
3966+
JSDocPrivateTag = 335,
3967+
JSDocProtectedTag = 336,
3968+
JSDocReadonlyTag = 337,
3969+
JSDocOverrideTag = 338,
3970+
JSDocCallbackTag = 339,
3971+
JSDocOverloadTag = 340,
3972+
JSDocEnumTag = 341,
3973+
JSDocParameterTag = 342,
3974+
JSDocReturnTag = 343,
3975+
JSDocThisTag = 344,
3976+
JSDocTypeTag = 345,
3977+
JSDocTemplateTag = 346,
3978+
JSDocTypedefTag = 347,
3979+
JSDocSeeTag = 348,
3980+
JSDocPropertyTag = 349,
3981+
JSDocThrowsTag = 350,
3982+
JSDocSatisfiesTag = 351,
3983+
JSDocImportTag = 352,
3984+
SyntaxList = 353,
3985+
NotEmittedStatement = 354,
3986+
PartiallyEmittedExpression = 355,
3987+
CommaListExpression = 356,
3988+
SyntheticReferenceExpression = 357,
3989+
Count = 358,
39893990
FirstAssignment = 64,
39903991
LastAssignment = 79,
39913992
FirstCompoundAssignment = 65,
@@ -4014,9 +4015,9 @@ declare namespace ts {
40144015
LastStatement = 259,
40154016
FirstNode = 166,
40164017
FirstJSDocNode = 309,
4017-
LastJSDocNode = 351,
4018+
LastJSDocNode = 352,
40184019
FirstJSDocTagNode = 327,
4019-
LastJSDocTagNode = 351,
4020+
LastJSDocTagNode = 352,
40204021
}
40214022
type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
40224023
type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -5721,6 +5722,9 @@ declare namespace ts {
57215722
interface JSDocDeprecatedTag extends JSDocTag {
57225723
kind: SyntaxKind.JSDocDeprecatedTag;
57235724
}
5725+
interface JSDocIgnoreTag extends JSDocTag {
5726+
kind: SyntaxKind.JSDocIgnoreTag;
5727+
}
57245728
interface JSDocClassTag extends JSDocTag {
57255729
readonly kind: SyntaxKind.JSDocClassTag;
57265730
}
@@ -7735,6 +7739,8 @@ declare namespace ts {
77357739
updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocComment> | undefined): JSDocUnknownTag;
77367740
createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
77377741
updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
7742+
createJSDocIgnoreTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocIgnoreTag;
7743+
updateJSDocIgnoreTag(node: JSDocIgnoreTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocIgnoreTag;
77387744
createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
77397745
updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
77407746
createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment>): JSDocThrowsTag;
@@ -8588,6 +8594,8 @@ declare namespace ts {
85888594
function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined;
85898595
/** Gets the JSDoc deprecated tag for the node if present */
85908596
function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined;
8597+
/** Gets the JSDoc ignore tag for the node if present */
8598+
function getJSDocIgnoreTag(node: Node): JSDocIgnoreTag | undefined;
85918599
/** Gets the JSDoc enum tag for the node if present */
85928600
function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined;
85938601
/** Gets the JSDoc this tag for the node if present */
@@ -9032,6 +9040,7 @@ declare namespace ts {
90329040
function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag;
90339041
function isJSDocOverloadTag(node: Node): node is JSDocOverloadTag;
90349042
function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag;
9043+
function isJSDocIgnoreTag(node: Node): node is JSDocIgnoreTag;
90359044
function isJSDocSeeTag(node: Node): node is JSDocSeeTag;
90369045
function isJSDocEnumTag(node: Node): node is JSDocEnumTag;
90379046
function isJSDocParameterTag(node: Node): node is JSDocParameterTag;

0 commit comments

Comments
 (0)