More thoroughly test navigateTo (#25239)

* More thoroughly test navigateTo

* Fix #25233 and #25237

* Update API (#24966)
This commit is contained in:
Andy
2018-07-02 19:25:27 -07:00
committed by GitHub
parent c3b81b3e10
commit efc1b7df08
45 changed files with 658 additions and 510 deletions

View File

@@ -4866,14 +4866,9 @@ namespace ts {
return !!(node as NamedDeclaration).name; // A 'name' property should always be a DeclarationName.
}
export function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined {
/** @internal */
export function getNonAssignedNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined {
switch (declaration.kind) {
case SyntaxKind.ClassExpression:
case SyntaxKind.FunctionExpression:
if (!(declaration as ClassExpression | FunctionExpression).name) {
return getAssignedName(declaration);
}
break;
case SyntaxKind.Identifier:
return declaration as Identifier;
case SyntaxKind.JSDocPropertyTag:
@@ -4906,6 +4901,12 @@ namespace ts {
return (declaration as NamedDeclaration).name;
}
export function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined {
if (declaration === undefined) return undefined;
return getNonAssignedNameOfDeclaration(declaration) ||
(isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
}
function getAssignedName(node: Node): DeclarationName | undefined {
if (!node.parent) {
return undefined;