TS: Disable export analysis for type-only exports

This commit is contained in:
Asger Feldthaus
2020-02-07 17:13:47 +00:00
parent 16c909b433
commit 47673c6e21
6 changed files with 25 additions and 1 deletions

View File

@@ -405,10 +405,16 @@ private class AnalyzedClosureGlobalAccessPath extends AnalyzedNode, AnalyzedProp
*/
private class AnalyzedExportNamespaceSpecifier extends AnalyzedPropertyWrite, DataFlow::ValueNode {
override ExportNamespaceSpecifier astNode;
ReExportDeclaration decl;
AnalyzedExportNamespaceSpecifier() {
decl = astNode.getExportDeclaration() and
not decl.isTypeOnly()
}
override predicate writesValue(AbstractValue baseVal, string propName, AbstractValue value) {
baseVal = TAbstractExportsObject(getTopLevel()) and
propName = astNode.getExportedName() and
value = TAbstractExportsObject(astNode.getExportDeclaration().(ReExportDeclaration).getReExportedModule())
value = TAbstractExportsObject(decl.getReExportedModule())
}
}

View File

@@ -0,0 +1 @@
export function f() {}

View File

@@ -0,0 +1,3 @@
import { ns } from "./importType";
ns.f(); // Calls local method in 'importType'

View File

@@ -0,0 +1,3 @@
export type * as ns from "./exportFunction";
export var ns = { f() {} };

View File

@@ -1,7 +1,14 @@
getAVarReference
| Foo | tst.ts:5:5:5:7 | Foo |
| f | exportFunction.ts:1:17:1:17 | f |
| ns | importFunction.ts:1:10:1:11 | ns |
| ns | importFunction.ts:3:1:3:2 | ns |
| ns | importType.ts:3:12:3:13 | ns |
getAnExportAccess
| Foo | tst.ts:3:15:3:17 | Foo |
getATypeDecl
| Foo | tst.ts:1:15:1:17 | Foo |
| ns | importFunction.ts:1:10:1:11 | ns |
| types | tst.ts:7:18:7:22 | types |
calls
| importFunction.ts:3:1:3:6 | ns.f() | importType.ts:3:19:3:24 | f() {} |

View File

@@ -11,3 +11,7 @@ query VarRef getAnExportAccess(LocalTypeName t) {
query TypeDecl getATypeDecl(LocalTypeName t) {
result = t.getADeclaration()
}
query Function calls(DataFlow::InvokeNode invoke) {
result = invoke.getACallee()
}