Skip to content

Commit 983eb19

Browse files
authored
Merge pull request #17433 from github/sidshank/ts-5.6
2 parents d374935 + bc70d5c commit 983eb19

File tree

12 files changed

+57
-27
lines changed

12 files changed

+57
-27
lines changed

docs/codeql/reusables/supported-versions-compilers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Python [8]_,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12",Not applicable,``.py``
2626
Ruby [9]_,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"
2727
Swift [10]_,"Swift 5.4-5.10","Swift compiler","``.swift``"
28-
TypeScript [11]_,"2.6-5.5",Standard TypeScript compiler,"``.ts``, ``.tsx``, ``.mts``, ``.cts``"
28+
TypeScript [11]_,"2.6-5.6",Standard TypeScript compiler,"``.ts``, ``.tsx``, ``.mts``, ``.cts``"
2929

3030
.. container:: footnote-group
3131

javascript/extractor/lib/typescript/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/extractor/lib/typescript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript-parser-wrapper",
33
"private": true,
44
"dependencies": {
5-
"typescript": "5.5.2"
5+
"typescript": "5.6.2"
66
},
77
"scripts": {
88
"build": "tsc --project tsconfig.json",
@@ -14,4 +14,4 @@
1414
"devDependencies": {
1515
"@types/node": "18.15.3"
1616
}
17-
}
17+
}

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,27 +1203,35 @@ private Node convertExportDeclaration(JsonObject node, SourceLocation loc) throw
12031203
Literal source = tryConvertChild(node, "moduleSpecifier", Literal.class);
12041204
Expression attributes = convertChild(node, "attributes");
12051205
if (hasChild(node, "exportClause")) {
1206+
JsonElement exportClauseNode = node.get("exportClause");
12061207
boolean hasTypeKeyword = node.get("isTypeOnly").getAsBoolean();
1208+
boolean isNamespaceExportNode = hasKind(exportClauseNode, "NamespaceExport");
12071209
List<ExportSpecifier> specifiers =
1208-
hasKind(node.get("exportClause"), "NamespaceExport")
1210+
isNamespaceExportNode
12091211
? Collections.singletonList(convertChild(node, "exportClause"))
1210-
: convertChildren(node.get("exportClause").getAsJsonObject(), "elements");
1212+
: convertChildren(exportClauseNode.getAsJsonObject(), "elements");
12111213
return new ExportNamedDeclaration(loc, null, specifiers, source, attributes, hasTypeKeyword);
12121214
} else {
12131215
return new ExportAllDeclaration(loc, source, attributes);
12141216
}
12151217
}
12161218

12171219
private Node convertExportSpecifier(JsonObject node, SourceLocation loc) throws ParseError {
1220+
Identifier local = convertChild(node, hasChild(node, "propertyName") ? "propertyName" : "name");
1221+
JsonObject exportedToken = node.get("name").getAsJsonObject();
1222+
Identifier exported = convertNodeAsIdentifier(exportedToken);
1223+
12181224
return new ExportSpecifier(
12191225
loc,
1220-
convertChild(node, hasChild(node, "propertyName") ? "propertyName" : "name"),
1221-
convertChild(node, "name"));
1226+
local,
1227+
exported);
12221228
}
12231229

12241230
private Node convertNamespaceExport(JsonObject node, SourceLocation loc) throws ParseError {
12251231
// Convert the "* as ns" from an export declaration.
1226-
return new ExportNamespaceSpecifier(loc, convertChild(node, "name"));
1232+
JsonObject exportedNamespaceToken = node.get("name").getAsJsonObject();
1233+
Identifier exportedNamespaceIdentifier = convertNodeAsIdentifier(exportedNamespaceToken);
1234+
return new ExportNamespaceSpecifier(loc, exportedNamespaceIdentifier);
12271235
}
12281236

12291237
private Node convertExpressionStatement(JsonObject node, SourceLocation loc) throws ParseError {
@@ -1431,7 +1439,8 @@ private Node convertImportKeyword(SourceLocation loc) {
14311439

14321440
private Node convertImportSpecifier(JsonObject node, SourceLocation loc) throws ParseError {
14331441
boolean hasImported = hasChild(node, "propertyName");
1434-
Identifier imported = convertChild(node, hasImported ? "propertyName" : "name");
1442+
JsonObject importedToken = node.get(hasImported? "propertyName" : "name").getAsJsonObject();
1443+
Identifier imported = convertNodeAsIdentifier(importedToken);
14351444
Identifier local = convertChild(node, "name");
14361445
boolean isTypeOnly = node.get("isTypeOnly").getAsBoolean() == true;
14371446
return new ImportSpecifier(loc, imported, local, isTypeOnly);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: majorAnalysis
3+
---
4+
* Added support for TypeScript 5.6.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { "Foo::new" as Foo_new } from "./foo.wasm"
2+
3+
const foo = Foo_new()
4+
5+
export { Foo_new as "Foo::new" }
6+
export type * as "Foo_types" from './mod'

javascript/ql/test/library-tests/Modules/tests.expected

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ test_BulkReExportDeclarations
33
test_ExportDeclarations
44
| a.js:1:1:3:1 | export ... n 23;\\n} |
55
| a.js:5:1:5:32 | export ... } = o; |
6-
| arbitarySpecifier.js:5:1:5:32 | export ... :new" } |
6+
| arbitrarySpecifier.ts:5:1:5:32 | export ... :new" } |
7+
| arbitrarySpecifier.ts:6:1:6:41 | export ... './mod' |
78
| b.js:5:1:5:18 | export { f as g }; |
89
| b.js:7:1:7:21 | export ... './a'; |
910
| d.js:4:1:4:20 | export * from 'm/c'; |
@@ -12,18 +13,20 @@ test_ExportDeclarations
1213
| es2015_require.js:3:1:3:25 | export ... ss C {} |
1314
| export-in-mjs.mjs:1:1:1:34 | export ... s = 42; |
1415
| f.ts:5:1:5:24 | export ... oo() {} |
16+
| jsArbitrarySpecifier.js:5:1:5:32 | export ... :new" } |
1517
| m/c.js:5:1:5:30 | export ... '../b'; |
1618
| reExportNamespace.js:1:1:1:26 | export ... "./a"; |
1719
| tst.html:7:3:7:22 | export const y = 42; |
1820
test_ExportDefaultDeclarations
1921
| a.js:1:1:3:1 | export ... n 23;\\n} |
2022
| es2015_require.js:3:1:3:25 | export ... ss C {} |
2123
test_ExportSpecifiers
22-
| arbitarySpecifier.js:5:10:5:30 | Foo_new ... o::new" | arbitarySpecifier.js:5:10:5:16 | Foo_new | arbitarySpecifier.js:5:10:5:30 | Foo_new ... o::new" |
24+
| arbitrarySpecifier.ts:5:10:5:30 | Foo_new ... o::new" | arbitrarySpecifier.ts:5:10:5:16 | Foo_new | arbitrarySpecifier.ts:5:21:5:30 | "Foo::new" |
2325
| b.js:5:10:5:15 | f as g | b.js:5:10:5:10 | f | b.js:5:15:5:15 | g |
2426
| e.js:2:10:2:10 | x | e.js:2:10:2:10 | x | e.js:2:10:2:10 | x |
2527
| e.js:2:13:2:13 | y | e.js:2:13:2:13 | y | e.js:2:13:2:13 | y |
2628
| e.js:3:10:3:21 | default as g | e.js:3:10:3:16 | default | e.js:3:21:3:21 | g |
29+
| jsArbitrarySpecifier.js:5:10:5:30 | Foo_new ... o::new" | jsArbitrarySpecifier.js:5:10:5:16 | Foo_new | jsArbitrarySpecifier.js:5:10:5:30 | Foo_new ... o::new" |
2730
| m/c.js:5:10:5:15 | g as h | m/c.js:5:10:5:10 | g | m/c.js:5:15:5:15 | h |
2831
test_GlobalVariableRef
2932
| a.js:5:31:5:31 | o |
@@ -43,7 +46,7 @@ test_ImportNamespaceSpecifier
4346
| exports.js:1:8:1:17 | * as dummy |
4447
| m/c.js:1:8:1:13 | * as b |
4548
test_ImportSpecifiers
46-
| arbitarySpecifier.js:1:10:1:30 | "Foo::n ... Foo_new | arbitarySpecifier.js:1:24:1:30 | Foo_new |
49+
| arbitrarySpecifier.ts:1:10:1:30 | "Foo::n ... Foo_new | arbitrarySpecifier.ts:1:24:1:30 | Foo_new |
4750
| b.js:1:8:1:8 | f | b.js:1:8:1:8 | f |
4851
| d.js:1:10:1:21 | default as g | d.js:1:21:1:21 | g |
4952
| d.js:1:24:1:29 | x as y | d.js:1:29:1:29 | y |
@@ -53,12 +56,13 @@ test_ImportSpecifiers
5356
| import-in-mjs.mjs:1:8:1:24 | exported_from_mjs | import-in-mjs.mjs:1:8:1:24 | exported_from_mjs |
5457
| import-ts-with-js-extension.ts:1:10:1:12 | foo | import-ts-with-js-extension.ts:1:10:1:12 | foo |
5558
| importcss.js:1:8:1:8 | A | importcss.js:1:8:1:8 | A |
59+
| jsArbitrarySpecifier.js:1:10:1:30 | "Foo::n ... Foo_new | jsArbitrarySpecifier.js:1:24:1:30 | Foo_new |
5660
| m/c.js:1:8:1:13 | * as b | m/c.js:1:13:1:13 | b |
5761
| reExportNamespaceClient.js:1:10:1:11 | ns | reExportNamespaceClient.js:1:10:1:11 | ns |
5862
| tst.html:5:10:5:10 | f | tst.html:5:10:5:10 | f |
5963
| unresolved.js:1:8:1:8 | f | unresolved.js:1:8:1:8 | f |
6064
test_Imports
61-
| arbitarySpecifier.js:1:1:1:50 | import ... o.wasm" | arbitarySpecifier.js:1:39:1:50 | "./foo.wasm" | 1 |
65+
| arbitrarySpecifier.ts:1:1:1:50 | import ... o.wasm" | arbitrarySpecifier.ts:1:39:1:50 | "./foo.wasm" | 1 |
6266
| b.js:1:1:1:20 | import f from './a'; | b.js:1:15:1:19 | './a' | 1 |
6367
| d.js:1:1:1:43 | import ... './a'; | d.js:1:38:1:42 | './a' | 2 |
6468
| d.js:2:1:2:13 | import './b'; | d.js:2:8:2:12 | './b' | 0 |
@@ -68,6 +72,7 @@ test_Imports
6872
| import-in-mjs.mjs:1:1:1:46 | import ... n-mjs'; | import-in-mjs.mjs:1:31:1:45 | 'export-in-mjs' | 1 |
6973
| import-ts-with-js-extension.ts:1:1:1:29 | import ... /f.js"; | import-ts-with-js-extension.ts:1:21:1:28 | "./f.js" | 1 |
7074
| importcss.js:1:1:1:24 | import ... a.css"; | importcss.js:1:15:1:23 | "./a.css" | 1 |
75+
| jsArbitrarySpecifier.js:1:1:1:50 | import ... o.wasm" | jsArbitrarySpecifier.js:1:39:1:50 | "./foo.wasm" | 1 |
7176
| m/c.js:1:1:1:26 | import ... '../b'; | m/c.js:1:20:1:25 | '../b' | 1 |
7277
| reExportNamespaceClient.js:1:1:1:41 | import ... space"; | reExportNamespaceClient.js:1:20:1:40 | "./reEx ... espace" | 1 |
7378
| tst.html:5:3:5:20 | import f from 'a'; | tst.html:5:17:5:19 | 'a' | 1 |
@@ -76,7 +81,8 @@ test_Module_exports
7681
| a.js:1:1:5:32 | <toplevel> | default | a.js:1:16:3:1 | functio ... n 23;\\n} |
7782
| a.js:1:1:5:32 | <toplevel> | x | a.js:5:18:5:20 | f() |
7883
| a.js:1:1:5:32 | <toplevel> | y | a.js:5:25:5:25 | y |
79-
| arbitarySpecifier.js:1:1:5:32 | <toplevel> | Foo::new | arbitarySpecifier.js:5:10:5:16 | Foo_new |
84+
| arbitrarySpecifier.ts:1:1:6:41 | <toplevel> | Foo::new | arbitrarySpecifier.ts:5:10:5:16 | Foo_new |
85+
| arbitrarySpecifier.ts:1:1:6:41 | <toplevel> | Foo_types | arbitrarySpecifier.ts:6:13:6:28 | * as "Foo_types" |
8086
| b.js:1:1:8:0 | <toplevel> | f2 | a.js:1:16:3:1 | functio ... n 23;\\n} |
8187
| b.js:1:1:8:0 | <toplevel> | g | b.js:5:10:5:10 | f |
8288
| e.js:1:1:4:0 | <toplevel> | g | a.js:1:16:3:1 | functio ... n 23;\\n} |
@@ -85,21 +91,24 @@ test_Module_exports
8591
| es2015_require.js:1:1:3:25 | <toplevel> | default | es2015_require.js:3:16:3:25 | class C {} |
8692
| export-in-mjs.mjs:1:1:1:34 | <toplevel> | exported_from_mjs | export-in-mjs.mjs:1:32:1:33 | 42 |
8793
| f.ts:1:1:6:0 | <toplevel> | foo | f.ts:5:8:5:24 | function foo() {} |
94+
| jsArbitrarySpecifier.js:1:1:5:32 | <toplevel> | Foo::new | jsArbitrarySpecifier.js:5:10:5:16 | Foo_new |
8895
| m/c.js:1:1:6:0 | <toplevel> | h | b.js:5:10:5:10 | f |
8996
| reExportNamespace.js:1:1:2:0 | <toplevel> | ns | reExportNamespace.js:1:8:1:14 | * as ns |
9097
| tst.html:4:23:8:0 | <toplevel> | y | tst.html:7:20:7:21 | 42 |
9198
test_NamedImportSpecifier
92-
| arbitarySpecifier.js:1:10:1:30 | "Foo::n ... Foo_new |
99+
| arbitrarySpecifier.ts:1:10:1:30 | "Foo::n ... Foo_new |
93100
| d.js:1:10:1:21 | default as g |
94101
| d.js:1:24:1:29 | x as y |
95102
| g.ts:1:9:1:11 | foo |
96103
| import-ts-with-js-extension.ts:1:10:1:12 | foo |
104+
| jsArbitrarySpecifier.js:1:10:1:30 | "Foo::n ... Foo_new |
97105
| reExportNamespaceClient.js:1:10:1:11 | ns |
98106
test_OtherImports
99107
| es2015_require.js:1:11:1:24 | require('./d') | d.js:1:1:5:0 | <toplevel> |
100108
| import-indirect-path.js:1:1:1:25 | require ... + '/a') | a.js:1:1:5:32 | <toplevel> |
101109
| import-indirect-path.js:5:1:5:14 | require(x + y) | a.js:1:1:5:32 | <toplevel> |
102110
test_ReExportDeclarations
111+
| arbitrarySpecifier.ts:6:1:6:41 | export ... './mod' | arbitrarySpecifier.ts:6:35:6:41 | './mod' |
103112
| b.js:7:1:7:21 | export ... './a'; | b.js:7:16:7:20 | './a' |
104113
| d.js:4:1:4:20 | export * from 'm/c'; | d.js:4:15:4:19 | 'm/c' |
105114
| e.js:3:1:3:35 | export ... './a'; | e.js:3:30:3:34 | './a' |
@@ -117,16 +126,18 @@ test_getAnImportedModule
117126
| library-tests/Modules/m/c.js | library-tests/Modules/b.js |
118127
| library-tests/Modules/reExportNamespaceClient.js | library-tests/Modules/reExportNamespace.js |
119128
test_getExportedName
120-
| arbitarySpecifier.js:5:10:5:30 | Foo_new ... o::new" | Foo::new |
129+
| arbitrarySpecifier.ts:5:10:5:30 | Foo_new ... o::new" | Foo::new |
130+
| arbitrarySpecifier.ts:6:13:6:28 | * as "Foo_types" | Foo_types |
121131
| b.js:5:10:5:15 | f as g | g |
122132
| b.js:7:8:7:9 | f2 | f2 |
123133
| e.js:2:10:2:10 | x | x |
124134
| e.js:2:13:2:13 | y | y |
125135
| e.js:3:10:3:21 | default as g | g |
136+
| jsArbitrarySpecifier.js:5:10:5:30 | Foo_new ... o::new" | Foo::new |
126137
| m/c.js:5:10:5:15 | g as h | h |
127138
| reExportNamespace.js:1:8:1:14 | * as ns | ns |
128139
test_getImportedName
129-
| arbitarySpecifier.js:1:10:1:30 | "Foo::n ... Foo_new | Foo::new |
140+
| arbitrarySpecifier.ts:1:10:1:30 | "Foo::n ... Foo_new | Foo::new |
130141
| b.js:1:8:1:8 | f | default |
131142
| d.js:1:10:1:21 | default as g | default |
132143
| d.js:1:24:1:29 | x as y | x |
@@ -135,22 +146,25 @@ test_getImportedName
135146
| import-in-mjs.mjs:1:8:1:24 | exported_from_mjs | default |
136147
| import-ts-with-js-extension.ts:1:10:1:12 | foo | foo |
137148
| importcss.js:1:8:1:8 | A | default |
149+
| jsArbitrarySpecifier.js:1:10:1:30 | "Foo::n ... Foo_new | Foo::new |
138150
| reExportNamespaceClient.js:1:10:1:11 | ns | ns |
139151
| tst.html:5:10:5:10 | f | default |
140152
| unresolved.js:1:8:1:8 | f | default |
141153
test_getLocalName
142-
| arbitarySpecifier.js:5:10:5:30 | Foo_new ... o::new" | Foo_new |
154+
| arbitrarySpecifier.ts:5:10:5:30 | Foo_new ... o::new" | Foo_new |
143155
| b.js:5:10:5:15 | f as g | f |
144156
| b.js:7:8:7:9 | f2 | default |
145157
| e.js:2:10:2:10 | x | x |
146158
| e.js:2:13:2:13 | y | y |
147159
| e.js:3:10:3:21 | default as g | default |
160+
| jsArbitrarySpecifier.js:5:10:5:30 | Foo_new ... o::new" | Foo_new |
148161
| m/c.js:5:10:5:15 | g as h | g |
149162
test_getSourceNode
150163
| a.js:1:1:3:1 | export ... n 23;\\n} | default | a.js:1:16:3:1 | functio ... n 23;\\n} |
151164
| a.js:5:1:5:32 | export ... } = o; | x | a.js:5:18:5:20 | f() |
152165
| a.js:5:1:5:32 | export ... } = o; | y | a.js:5:25:5:25 | y |
153-
| arbitarySpecifier.js:5:1:5:32 | export ... :new" } | Foo::new | arbitarySpecifier.js:5:10:5:16 | Foo_new |
166+
| arbitrarySpecifier.ts:5:1:5:32 | export ... :new" } | Foo::new | arbitrarySpecifier.ts:5:10:5:16 | Foo_new |
167+
| arbitrarySpecifier.ts:6:1:6:41 | export ... './mod' | Foo_types | arbitrarySpecifier.ts:6:13:6:28 | * as "Foo_types" |
154168
| b.js:5:1:5:18 | export { f as g }; | g | b.js:5:10:5:10 | f |
155169
| b.js:7:1:7:21 | export ... './a'; | f2 | a.js:1:16:3:1 | functio ... n 23;\\n} |
156170
| e.js:2:1:2:16 | export { x, y }; | x | e.js:2:10:2:10 | x |
@@ -159,6 +173,7 @@ test_getSourceNode
159173
| es2015_require.js:3:1:3:25 | export ... ss C {} | default | es2015_require.js:3:16:3:25 | class C {} |
160174
| export-in-mjs.mjs:1:1:1:34 | export ... s = 42; | exported_from_mjs | export-in-mjs.mjs:1:32:1:33 | 42 |
161175
| f.ts:5:1:5:24 | export ... oo() {} | foo | f.ts:5:8:5:24 | function foo() {} |
176+
| jsArbitrarySpecifier.js:5:1:5:32 | export ... :new" } | Foo::new | jsArbitrarySpecifier.js:5:10:5:16 | Foo_new |
162177
| m/c.js:5:1:5:30 | export ... '../b'; | h | b.js:5:10:5:10 | f |
163178
| reExportNamespace.js:1:1:1:26 | export ... "./a"; | ns | reExportNamespace.js:1:8:1:14 | * as ns |
164179
| tst.html:7:3:7:22 | export const y = 42; | y | tst.html:7:20:7:21 | 42 |

javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ classDeclaration
33
| test_tsx.vue:3:18:5:3 | class M ... er;\\n } |
44
exprType
55
| htmlfile.html:4:22:4:24 | foo | () => void |
6-
| htmlfile.html:4:22:4:24 | foo | () => void |
76
| htmlfile.html:4:33:4:41 | "./other" | any |
87
| htmlfile.html:5:17:5:22 | result | number[] |
98
| htmlfile.html:5:26:5:28 | foo | () => void |
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
| bar.ts:1:10:1:10 | A | any |
2-
| bar.ts:1:10:1:10 | A | any |
32
| bar.ts:1:19:1:29 | "@blah/foo" | any |
43
| bar.ts:3:5:3:5 | x | A |
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
| test.ts:1:10:1:12 | foo | () => any |
2-
| test.ts:1:10:1:12 | foo | () => any |
32
| test.ts:1:21:1:25 | "foo" | any |
43
| test.ts:3:1:3:3 | foo | () => any |
54
| test.ts:3:1:3:5 | foo() | any |

javascript/ql/test/library-tests/TypeScript/Types/tests.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@ getExprType
474474
| tst.ts:358:13:358:23 | tstModuleES | () => "a" \| "b" |
475475
| tst.ts:358:13:358:25 | tstModuleES() | "a" \| "b" |
476476
| tst.ts:360:10:360:21 | tstModuleCJS | () => "a" \| "b" |
477-
| tst.ts:360:10:360:21 | tstModuleCJS | () => "a" \| "b" |
478477
| tst.ts:360:30:360:49 | './tstModuleCJS.cjs' | any |
479478
| tst.ts:362:1:362:7 | console | Console |
480479
| tst.ts:362:1:362:11 | console.log | (...data: any[]) => void |

0 commit comments

Comments
 (0)