Fix bug for constructor with modifier

This commit is contained in:
Andy Hanson 2017-01-13 08:10:58 -08:00
parent 2711303539
commit 639f5cb6e5
3 changed files with 13 additions and 4 deletions

View file

@ -502,9 +502,8 @@ namespace ts.FindAllReferences {
const result: Node[] = [];
for (const decl of classSymbol.members["__constructor"].declarations) {
Debug.assert(decl.kind === SyntaxKind.Constructor);
const ctrKeyword = decl.getChildAt(0);
Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword);
const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)!
Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword);
result.push(ctrKeyword);
}

View file

@ -600,7 +600,7 @@ namespace ts {
return !!findChildOfKind(n, kind, sourceFile);
}
export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node {
export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined {
return forEach(n.getChildren(sourceFile), c => c.kind === kind && c);
}

View file

@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />
////class X {
//// public [|constructor|]() {}
////}
////var x = new [|X|]();
const ranges = test.ranges();
const ctr = ranges[0];
verify.referencesOf(ctr, ranges);