Skip to content

Commit 8841f43

Browse files
committed
Add missing BinaryExpression tokens
1 parent 6557da1 commit 8841f43

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/graphqlsp/src/ast/declaration.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ export function isValueDeclaration(node: ts.Node): node is ValueDeclaration {
7373
}
7474
}
7575

76+
/** Returns true if operator assigns a value unchanged */
77+
function isAssignmentOperator(token: ts.BinaryOperatorToken): boolean {
78+
switch (token.kind) {
79+
case ts.SyntaxKind.EqualsToken:
80+
case ts.SyntaxKind.BarBarEqualsToken:
81+
case ts.SyntaxKind.AmpersandAmpersandEqualsToken:
82+
case ts.SyntaxKind.QuestionQuestionEqualsToken:
83+
return true;
84+
default:
85+
return false;
86+
}
87+
}
88+
7689
/** Evaluates to the declaration's value initializer or itself if it declares a value */
7790
export function getValueOfValueDeclaration(
7891
node: ValueDeclaration
@@ -99,9 +112,7 @@ export function getValueOfValueDeclaration(
99112
case ts.SyntaxKind.VariableDeclaration:
100113
return node.initializer;
101114
case ts.SyntaxKind.BinaryExpression:
102-
return node.operatorToken.kind === ts.SyntaxKind.EqualsToken
103-
? node.right
104-
: undefined;
115+
return isAssignmentOperator(node.operatorToken) ? node.right : undefined;
105116
case ts.SyntaxKind.ShorthandPropertyAssignment:
106117
return node.objectAssignmentInitializer;
107118
default:

0 commit comments

Comments
 (0)