Skip to content

Commit dc454d3

Browse files
committed
add support for the new using keyword in TypeScript
1 parent a7d92b3 commit dc454d3

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

javascript/extractor/src/com/semmle/ts/extractor/TypeScriptASTConverter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,10 +2683,13 @@ private boolean hasKind(JsonElement node, String kind) {
26832683
}
26842684

26852685
/**
2686-
* Gets the declaration kind of the given node, which is one of {@code "var"}, {@code "let"} or
2687-
* {@code "const"}.
2686+
* Gets the declaration kind of the given node, which is one of {@code "var"}, {@code "let"},
2687+
* {@code "const"}, or {@code "using"}.
26882688
*/
26892689
private String getDeclarationKind(JsonObject declarationList) {
2690+
if (hasFlag(declarationList, "Using")) {
2691+
return "using";
2692+
}
26902693
return declarationList.get("$declarationKind").getAsString();
26912694
}
26922695
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
consts
2+
| tst.tsx:2:3:2:26 | const { ... } = o; |
3+
| tst.tsx:9:5:9:26 | const b ... efined; |
4+
usings
5+
| tst.tsx:7:5:7:28 | using f ... as any; |
6+
#select
17
| tst.tsx:1:10:1:10 | f |
28
| tst.tsx:1:12:1:12 | o |
39
| tst.tsx:2:14:2:14 | v |
10+
| tst.tsx:6:10:6:10 | v |
11+
| tst.tsx:7:11:7:13 | foo |
12+
| tst.tsx:9:11:9:13 | bar |

javascript/ql/test/library-tests/TypeScript/BindingPattern/VarDecl.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ import javascript
22

33
from VarDecl decl
44
select decl
5+
6+
query ConstDeclStmt consts() { any() }
7+
8+
query UsingDeclStmt usings() { any() }

javascript/ql/test/library-tests/TypeScript/BindingPattern/tst.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ function f(o) {
22
const { p: v = [] } = o;
33
return v;
44
}
5+
6+
function v() {
7+
using foo = null as any;
8+
9+
const bar = undefined;
10+
}

0 commit comments

Comments
 (0)