Skip to content

Commit 413f0fa

Browse files
Andaristgabritto
andauthored
Fixed crash when looking for contextual inherited JSDocs for setters and getters (#60027)
Co-authored-by: Gabriela Araujo Britto <[email protected]>
1 parent e962037 commit 413f0fa

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/services/services.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ class SymbolObject implements Symbol {
735735
if (context) {
736736
if (isGetAccessor(context)) {
737737
if (!this.contextualGetAccessorDocumentationComment) {
738+
this.contextualGetAccessorDocumentationComment = emptyArray; // Set temporarily to avoid an infinite loop finding inherited tags
739+
738740
this.contextualGetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isGetAccessor), checker);
739741
}
740742
if (length(this.contextualGetAccessorDocumentationComment)) {
@@ -743,6 +745,8 @@ class SymbolObject implements Symbol {
743745
}
744746
if (isSetAccessor(context)) {
745747
if (!this.contextualSetAccessorDocumentationComment) {
748+
this.contextualSetAccessorDocumentationComment = emptyArray; // Set temporarily to avoid an infinite loop finding inherited tags
749+
746750
this.contextualSetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isSetAccessor), checker);
747751
}
748752
if (length(this.contextualSetAccessorDocumentationComment)) {
@@ -766,6 +770,8 @@ class SymbolObject implements Symbol {
766770
if (context) {
767771
if (isGetAccessor(context)) {
768772
if (!this.contextualGetAccessorTags) {
773+
this.contextualGetAccessorTags = emptyArray; // Set temporarily to avoid an infinite loop finding inherited tags
774+
769775
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(filter(this.declarations, isGetAccessor), checker);
770776
}
771777
if (length(this.contextualGetAccessorTags)) {
@@ -774,6 +780,8 @@ class SymbolObject implements Symbol {
774780
}
775781
if (isSetAccessor(context)) {
776782
if (!this.contextualSetAccessorTags) {
783+
this.contextualSetAccessorTags = emptyArray; // Set temporarily to avoid an infinite loop finding inherited tags
784+
777785
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(filter(this.declarations, isSetAccessor), checker);
778786
}
779787
if (length(this.contextualSetAccessorTags)) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// https://github.com/microsoft/TypeScript/issues/60024
4+
5+
//// class A implements A {
6+
//// get x(): string { return "" }
7+
//// }
8+
//// const e = new A()
9+
//// e.x/*1*/
10+
////
11+
//// class B implements B {
12+
//// set x(v: string) {}
13+
//// }
14+
//// const f = new B()
15+
//// f.x/*2*/
16+
17+
verify.quickInfoAt("1", "(property) A.x: string");
18+
verify.quickInfoAt("2", "(property) B.x: string");

0 commit comments

Comments
 (0)