File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
packages/graphqlsp/src/ast Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ export function isValueDeclaration(node: ts.Node): node is ValueDeclaration {
73
73
}
74
74
}
75
75
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
+
76
89
/** Evaluates to the declaration's value initializer or itself if it declares a value */
77
90
export function getValueOfValueDeclaration (
78
91
node : ValueDeclaration
@@ -99,9 +112,7 @@ export function getValueOfValueDeclaration(
99
112
case ts . SyntaxKind . VariableDeclaration :
100
113
return node . initializer ;
101
114
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 ;
105
116
case ts . SyntaxKind . ShorthandPropertyAssignment :
106
117
return node . objectAssignmentInitializer ;
107
118
default :
You can’t perform that action at this time.
0 commit comments