Merge pull request #32 from asger-semmle/export-import-flow

TypeScript: bugfixes for import-assign statement
This commit is contained in:
Max Schaefer
2018-08-08 16:35:43 +01:00
committed by GitHub
5 changed files with 16 additions and 3 deletions

View File

@@ -43,8 +43,8 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) {
exists (EnumDeclaration ed | def = ed.getIdentifier() |
lhs = def and rhs = ed
) or
exists (ImportEqualsDeclaration i | def = i.getId() |
lhs = def and rhs = i.getImportedEntity()
exists (ImportEqualsDeclaration i | def = i |
lhs = i.getId() and rhs = i.getImportedEntity()
) or
exists (EnumMember member | def = member.getIdentifier() |
lhs = def and rhs = member.getInitializer()

View File

@@ -308,7 +308,8 @@ class ExportNamedDeclaration extends ExportDeclaration, @exportnameddeclaration
result = op.(NamespaceDeclaration).getId() or
result = op.(EnumDeclaration).getIdentifier() or
result = op.(InterfaceDeclaration).getIdentifier() or
result = op.(TypeAliasDeclaration).getIdentifier()
result = op.(TypeAliasDeclaration).getIdentifier() or
result = op.(ImportEqualsDeclaration).getId()
)
}

View File

@@ -224,6 +224,10 @@ class ImportEqualsDeclaration extends Stmt, @importequalsdeclaration {
Expr getImportedEntity() {
result = getChildExpr(1)
}
override ControlFlowNode getFirstControlFlowNode() {
result = getId()
}
}
/**

View File

@@ -0,0 +1,3 @@
import * as Something from 'somewhere';
export import importExport = Something.thingy;

View File

@@ -0,0 +1,5 @@
import { importExport } from "./export_import";
function test() {
let f = importExport.prop; // OK
}