Skip to content

Commit 1476d7e

Browse files
author
Andy
authored
Merge pull request #13469 from Microsoft/public_constructor
Fix bug for constructor with modifier
2 parents 2711303 + 639f5cb commit 1476d7e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/services/findAllReferences.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,8 @@ namespace ts.FindAllReferences {
502502
const result: Node[] = [];
503503

504504
for (const decl of classSymbol.members["__constructor"].declarations) {
505-
Debug.assert(decl.kind === SyntaxKind.Constructor);
506-
const ctrKeyword = decl.getChildAt(0);
507-
Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword);
505+
const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)!
506+
Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword);
508507
result.push(ctrKeyword);
509508
}
510509

src/services/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ namespace ts {
600600
return !!findChildOfKind(n, kind, sourceFile);
601601
}
602602

603-
export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node {
603+
export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined {
604604
return forEach(n.getChildren(sourceFile), c => c.kind === kind && c);
605605
}
606606

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////class X {
4+
//// public [|constructor|]() {}
5+
////}
6+
////var x = new [|X|]();
7+
8+
const ranges = test.ranges();
9+
const ctr = ranges[0];
10+
verify.referencesOf(ctr, ranges);

0 commit comments

Comments
 (0)