File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
javascript/ql/lib/semmle/javascript/internal Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ private import javascript
1010module TypeResolution {
1111 private class NodeBase =
1212 @expr or @typeexpr or @lexical_name or @toplevel or @function_decl_stmt or @class_decl_stmt or
13- @namespace_declaration or @enum_declaration;
13+ @namespace_declaration or @enum_declaration or @jsdoc_type_expr ;
1414
1515 /**
1616 * A node in a graph which we use to perform name and type resolution.
@@ -20,12 +20,16 @@ module TypeResolution {
2020 result = this .( AstNode ) .toString ( )
2121 or
2222 result = this .( LexicalName ) .toString ( )
23+ or
24+ result = this .( JSDocTypeExpr ) .toString ( )
2325 }
2426
2527 Location getLocation ( ) {
2628 result = this .( AstNode ) .getLocation ( )
2729 or
2830 result = this .( LocalVariable ) .getLocation ( )
31+ or
32+ result = this .( JSDocTypeExpr ) .getLocation ( )
2933 }
3034 }
3135
Original file line number Diff line number Diff line change @@ -104,6 +104,31 @@ module UnderlyingTypes {
104104 node1 = e .getExpression ( ) and
105105 node2 = e
106106 )
107+ or
108+ exists ( JSDocUnionTypeExpr type |
109+ node1 = type .getAnAlternative ( ) and
110+ node2 = type
111+ )
112+ or
113+ exists ( JSDocNonNullableTypeExpr type |
114+ node1 = type .getTypeExpr ( ) and
115+ node2 = type
116+ )
117+ or
118+ exists ( JSDocNullableTypeExpr type |
119+ node1 = type .getTypeExpr ( ) and
120+ node2 = type
121+ )
122+ or
123+ exists ( JSDocAppliedTypeExpr type |
124+ node1 = type .getHead ( ) and
125+ node2 = type
126+ )
127+ or
128+ exists ( JSDocOptionalParameterTypeExpr type |
129+ node1 = type .getUnderlyingType ( ) and
130+ node2 = type
131+ )
107132 }
108133
109134 bindingset [ a, b]
@@ -123,6 +148,12 @@ module UnderlyingTypes {
123148 name = append ( prefix , step )
124149 )
125150 or
151+ exists ( JSDocNamedTypeExpr type |
152+ node = type and
153+ type .hasQualifiedName ( name ) and
154+ mod = "global"
155+ )
156+ or
126157 exists ( Node mid | nodeHasUnderlyingType ( mid , mod , name ) |
127158 TypeFlow:: step ( mid , node )
128159 or
You can’t perform that action at this time.
0 commit comments