Skip to content

Commit cee75ae

Browse files
committed
JS: Support unqualified jsdoc names
1 parent be1cd98 commit cee75ae

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

javascript/ql/lib/semmle/javascript/Variables.qll

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class Scope extends @scope {
2727
result = this.getAVariable() and
2828
result.getName() = name
2929
}
30+
31+
/** Gets the local type name with the given name declared in this scope. */
32+
LocalTypeName getLocalTypeName(string name) {
33+
result.getScope() = this and
34+
result.getName() = name
35+
}
3036
}
3137

3238
/**

javascript/ql/lib/semmle/javascript/internal/TypeResolution.qll

+6
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ module TypeResolution {
132132
node1 = type.getExpressionName() and
133133
node2 = type
134134
)
135+
or
136+
exists(JSDocNamedTypeExpr type, string name |
137+
type.hasNameParts(name, "") and
138+
node1 = type.getTopLevel().getScope().getLocalTypeName(name) and
139+
node2 = type
140+
)
135141
}
136142

137143
/**

javascript/ql/test/library-tests/UnderlyingTypes/jsdoc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ function t1(req) { // $ hasUnderlyingType='express'.Request SPURIOUS: hasUnderly
1010
/**
1111
* @param {Response} res
1212
*/
13-
function t2(res) { // $ MISSING: hasUnderlyingType='express'.Response SPURIOUS: hasUnderlyingType=Response
13+
function t2(res) { // $ hasUnderlyingType='express'.Response SPURIOUS: hasUnderlyingType=Response
1414
}

0 commit comments

Comments
 (0)