Skip to content

Commit 81b6588

Browse files
Make isDeclaration return 'true' on FunctionExpressions.
1 parent 21fb559 commit 81b6588

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10190,7 +10190,7 @@ module ts {
1019010190
}
1019110191

1019210192
function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol {
10193-
if (isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
10193+
if (isDeclarationOrCatchVariableName(entityName)) {
1019410194
return getSymbolOfNode(entityName.parent);
1019510195
}
1019610196

@@ -10255,7 +10255,7 @@ module ts {
1025510255
return undefined;
1025610256
}
1025710257

10258-
if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
10258+
if (isDeclarationOrCatchVariableName(node)) {
1025910259
// This is a declaration, call getSymbolOfNode
1026010260
return getSymbolOfNode(node.parent);
1026110261
}
@@ -10351,7 +10351,7 @@ module ts {
1035110351
return getTypeOfSymbol(symbol);
1035210352
}
1035310353

10354-
if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
10354+
if (isDeclarationOrCatchVariableName(node)) {
1035510355
var symbol = getSymbolInfo(node);
1035610356
return symbol && getTypeOfSymbol(symbol);
1035710357
}

src/compiler/utilities.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ module ts {
706706
case SyntaxKind.ImportSpecifier:
707707
case SyntaxKind.NamespaceImport:
708708
case SyntaxKind.ExportSpecifier:
709+
case SyntaxKind.FunctionExpression:
709710
return true;
710711
}
711712
return false;
@@ -739,7 +740,7 @@ module ts {
739740
}
740741

741742
// True if the given identifier, string literal, or number literal is the name of a declaration node
742-
export function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean {
743+
export function isDeclarationOrCatchVariableName(name: Node): boolean {
743744
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {
744745
return false;
745746
}
@@ -751,7 +752,7 @@ module ts {
751752
}
752753
}
753754

754-
if (isDeclaration(parent) || parent.kind === SyntaxKind.FunctionExpression) {
755+
if (isDeclaration(parent)) {
755756
return (<Declaration>parent).name === name;
756757
}
757758

src/services/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,7 +4756,7 @@ module ts {
47564756

47574757
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
47584758
function isWriteAccess(node: Node): boolean {
4759-
if (node.kind === SyntaxKind.Identifier && isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
4759+
if (node.kind === SyntaxKind.Identifier && isDeclarationOrCatchVariableName(node)) {
47604760
return true;
47614761
}
47624762

@@ -4918,7 +4918,7 @@ module ts {
49184918
else if (isInRightSideOfImport(node)) {
49194919
return getMeaningFromRightHandSideOfImportEquals(node);
49204920
}
4921-
else if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
4921+
else if (isDeclarationOrCatchVariableName(node)) {
49224922
return getMeaningFromDeclaration(node.parent);
49234923
}
49244924
else if (isTypeReference(node)) {

0 commit comments

Comments
 (0)