TS: Add test for named re-export and exportsAs

This commit is contained in:
Asger Feldthaus
2020-02-24 11:38:05 +00:00
parent 78954489fb
commit 01309d7c2e
5 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1 @@
export class C {}

View File

@@ -0,0 +1,3 @@
import type { C } from "./namedReexport";
let c: C;

View File

@@ -0,0 +1 @@
export type { C } from "./exportClass";

View File

@@ -1,5 +1,7 @@
getAVarReference
| C | exportClass.ts:1:14:1:14 | C |
| Foo | tst.ts:5:5:5:7 | Foo |
| c | importRexportedClass.ts:3:5:3:5 | c |
| f | exportFunction.ts:1:17:1:17 | f |
| ns | importFunction.ts:1:10:1:11 | ns |
| ns | importFunction.ts:3:1:3:2 | ns |
@@ -7,8 +9,18 @@ getAVarReference
getAnExportAccess
| Foo | tst.ts:3:15:3:17 | Foo |
getATypeDecl
| C | exportClass.ts:1:14:1:14 | C |
| C | importRexportedClass.ts:1:15:1:15 | C |
| 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() {} |
exportsAs
| exportClass.ts:1:1:1:17 | export class C {} | C | C | type |
| exportClass.ts:1:1:1:17 | export class C {} | C | C | variable |
| exportFunction.ts:1:1:1:22 | export ... f() {} | f | f | variable |
| importType.ts:3:1:3:27 | export ... ) {} }; | ns | ns | variable |
| namedReexport.ts:1:1:1:39 | export ... Class"; | C | C | type |
| tst.ts:3:1:3:20 | export type { Foo }; | Foo | Foo | namespace |
| tst.ts:3:1:3:20 | export type { Foo }; | Foo | Foo | type |

View File

@@ -15,3 +15,8 @@ query TypeDecl getATypeDecl(LocalTypeName t) {
query Function calls(DataFlow::InvokeNode invoke) {
result = invoke.getACallee()
}
query predicate exportsAs(ExportDeclaration exprt, LexicalName v, string name, string kind) {
exprt.exportsAs(v, name) and
kind = v.getDeclarationSpace()
}