Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0de9eed

Browse files
author
Max Schaefer
authored
Merge pull request #32 from asger-semmle/export-import-flow
TypeScript: bugfixes for import-assign statement
2 parents 355302e + 94bac12 commit 0de9eed

5 files changed

Lines changed: 16 additions & 3 deletions

File tree

javascript/ql/src/semmle/javascript/DefUse.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) {
4343
exists (EnumDeclaration ed | def = ed.getIdentifier() |
4444
lhs = def and rhs = ed
4545
) or
46-
exists (ImportEqualsDeclaration i | def = i.getId() |
47-
lhs = def and rhs = i.getImportedEntity()
46+
exists (ImportEqualsDeclaration i | def = i |
47+
lhs = i.getId() and rhs = i.getImportedEntity()
4848
) or
4949
exists (EnumMember member | def = member.getIdentifier() |
5050
lhs = def and rhs = member.getInitializer()

javascript/ql/src/semmle/javascript/ES2015Modules.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ class ExportNamedDeclaration extends ExportDeclaration, @exportnameddeclaration
308308
result = op.(NamespaceDeclaration).getId() or
309309
result = op.(EnumDeclaration).getIdentifier() or
310310
result = op.(InterfaceDeclaration).getIdentifier() or
311-
result = op.(TypeAliasDeclaration).getIdentifier()
311+
result = op.(TypeAliasDeclaration).getIdentifier() or
312+
result = op.(ImportEqualsDeclaration).getId()
312313
)
313314
}
314315

javascript/ql/src/semmle/javascript/TypeScript.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ class ImportEqualsDeclaration extends Stmt, @importequalsdeclaration {
224224
Expr getImportedEntity() {
225225
result = getChildExpr(1)
226226
}
227+
228+
override ControlFlowNode getFirstControlFlowNode() {
229+
result = getId()
230+
}
227231
}
228232

229233
/**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as Something from 'somewhere';
2+
3+
export import importExport = Something.thingy;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { importExport } from "./export_import";
2+
3+
function test() {
4+
let f = importExport.prop; // OK
5+
}

0 commit comments

Comments
 (0)