Skip to content

Commit 94c8ec8

Browse files
committed
JS: Fix support for selective re-export
1 parent 885920c commit 94c8ec8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ module TypeResolution {
167167
node2 = spec.getLocal()
168168
)
169169
or
170+
exists(SelectiveReExportDeclaration exprt, ExportSpecifier spec |
171+
spec = exprt.getASpecifier() and
172+
node1 = exprt.getImportedPath() and
173+
name = spec.getLocalName() and
174+
node2 = spec.getLocal()
175+
)
176+
or
170177
// Support JSDoc expressions of the form 'foo.bar' where 'foo' is an import
171178
// at the top-level.
172179
exists(JSDocNamedTypeExpr expr, string prefix |
@@ -234,6 +241,16 @@ module TypeResolution {
234241
name = spec.getExportedName()
235242
)
236243
or
244+
exists(SelectiveReExportDeclaration exprt, ExportSpecifier spec |
245+
// `export { A as B } from 'blah'`
246+
// This is not covered by `exportsAs` above because neither A or B is a LexicalName
247+
// (both are property names) so it doesn't fit the interface of `exportsAs`.
248+
spec = exprt.getASpecifier() and
249+
mod = exprt.getContainer() and
250+
name = spec.getExportedName() and
251+
result = spec.getLocal()
252+
)
253+
or
237254
exists(EnumDeclaration enum |
238255
mod = enum and
239256
result = enum.getMemberByName(name).getIdentifier()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Request, Response, R } from './expressSelectiveExport';
22

3-
function t1(req: Request) { // $ MISSING: hasUnderlyingType='express'.Request
3+
function t1(req: Request) { // $ hasUnderlyingType='express'.Request
44
}
55

66
function t2(res: Response) { // none, not exported
77
}
88

9-
function t3(res: R) { // $ MISSING: hasUnderlyingType='express'.Response
9+
function t3(res: R) { // $ hasUnderlyingType='express'.Response
1010
}

0 commit comments

Comments
 (0)