Skip to content

Commit ac85b6e

Browse files
authored
Merge pull request github#12011 from erik-krogh/ts50
JS: Add support for TypeScript 5.0
2 parents 0cadf4d + f1094cd commit ac85b6e

File tree

11 files changed

+703
-45
lines changed

11 files changed

+703
-45
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
JavaScript,ECMAScript 2022 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhtm``, ``.xhtml``, ``.vue``, ``.hbs``, ``.ejs``, ``.njk``, ``.json``, ``.yaml``, ``.yml``, ``.raml``, ``.xml`` [7]_"
2525
Python [8]_,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11",Not applicable,``.py``
2626
Ruby [9]_,"up to 3.1",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"
27-
TypeScript [10]_,"2.6-4.9",Standard TypeScript compiler,"``.ts``, ``.tsx``, ``.mts``, ``.cts``"
27+
TypeScript [10]_,"2.6-5.0",Standard TypeScript compiler,"``.ts``, ``.tsx``, ``.mts``, ``.cts``"
2828

2929
.. container:: footnote-group
3030

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": "4.9.3"
5+
"typescript": "5.0.2"
66
},
77
"scripts": {
88
"build": "tsc --project tsconfig.json",
@@ -12,6 +12,6 @@
1212
"watch": "tsc -p . -w --sourceMap"
1313
},
1414
"devDependencies": {
15-
"@types/node": "12.7.11"
15+
"@types/node": "18.15.3"
1616
}
1717
}

javascript/extractor/lib/typescript/src/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ const astProperties: string[] = [
242242
"constructor",
243243
"declarationList",
244244
"declarations",
245-
"illegalDecorators",
246245
"default",
247246
"delete",
248247
"dotDotDotToken",

javascript/extractor/lib/typescript/src/type_table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ export class TypeTable {
947947
* Returns a unique string for the given call/constructor signature.
948948
*/
949949
private getSignatureString(kind: ts.SignatureKind, signature: AugmentedSignature): string {
950-
let modifiers = signature.getDeclaration()?.modifiers;
950+
let modifiers = signature.getDeclaration() ? ts.getModifiers(signature.getDeclaration() as ts.MethodSignature) : [];
951951
let isAbstract = modifiers && modifiers.filter(modifier => modifier.kind == ts.SyntaxKind.AbstractKeyword).length > 0
952952

953953
let parameters = signature.getParameters();

javascript/extractor/lib/typescript/yarn.lock

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# yarn lockfile v1
33

44

5-
6-
version "12.7.11"
7-
resolved node-12.7.11.tgz#be879b52031cfb5d295b047f5462d8ef1a716446
5+
6+
version "18.15.3"
7+
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.3.tgz#f0b991c32cfc6a4e7f3399d6cb4b8cf9a0315014"
8+
integrity sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==
89

9-
typescript@4.9.3:
10-
version "4.9.3"
11-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db"
12-
integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==
10+
typescript@5.0.2:
11+
version "5.0.2"
12+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.2.tgz#891e1a90c5189d8506af64b9ef929fca99ba1ee5"
13+
integrity sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==

javascript/extractor/src/com/semmle/js/extractor/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Main {
4141
* A version identifier that should be updated every time the extractor changes in such a way that
4242
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
4343
*/
44-
public static final String EXTRACTOR_VERSION = "2023-03-03";
44+
public static final String EXTRACTOR_VERSION = "2023-03-16";
4545

4646
public static final Pattern NEWLINE = Pattern.compile("\n");
4747

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ private Node convertEnumDeclaration(JsonObject node, SourceLocation loc) throws
11591159
loc,
11601160
hasModifier(node, "ConstKeyword"),
11611161
hasModifier(node, "DeclareKeyword"),
1162-
convertChildrenNotNull(node, "illegalDecorators"), // as of https://github.com/microsoft/TypeScript/pull/50343/ the property is called `illegalDecorators` instead of `decorators`
1162+
getDecorators(node),
11631163
convertChild(node, "name"),
11641164
convertChildren(node, "members"));
11651165
attachSymbolInformation(enumDeclaration, node);
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.0.

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

Lines changed: 525 additions & 31 deletions
Large diffs are not rendered by default.

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

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,79 @@ getExprType
560560
| tst.ts:423:7:423:22 | this.name = name | string |
561561
| tst.ts:423:12:423:15 | name | string |
562562
| tst.ts:423:19:423:22 | name | string |
563+
| tst.ts:430:8:430:11 | TS50 | typeof TS50 in library-tests/TypeScript/Types/tst.ts |
564+
| tst.ts:432:33:432:36 | args | Args |
565+
| tst.ts:433:68:433:71 | args | Args |
566+
| tst.ts:435:15:435:24 | methodName | string |
567+
| tst.ts:435:28:435:33 | String | StringConstructor |
568+
| tst.ts:435:28:435:47 | String(context.name) | string |
569+
| tst.ts:435:35:435:46 | context.name | string \| symbol |
570+
| tst.ts:435:43:435:46 | name | string \| symbol |
571+
| tst.ts:437:51:437:54 | args | Args |
572+
| tst.ts:438:13:438:19 | console | Console |
573+
| tst.ts:438:13:438:23 | console.log | (...data: any[]) => void |
574+
| tst.ts:438:13:438:64 | console ... me}'.`) | void |
575+
| tst.ts:438:21:438:23 | log | (...data: any[]) => void |
576+
| tst.ts:438:25:438:63 | `LOG: E ... ame}'.` | string |
577+
| tst.ts:438:26:438:47 | LOG: En ... ethod ' | any |
578+
| tst.ts:438:50:438:59 | methodName | string |
579+
| tst.ts:438:61:438:62 | '. | any |
580+
| tst.ts:439:19:439:24 | result | any |
581+
| tst.ts:439:28:439:38 | target.call | (this: Function, thisArg: any, ...argArray: any... |
582+
| tst.ts:439:28:439:53 | target. ... ..args) | any |
583+
| tst.ts:439:35:439:38 | call | (this: Function, thisArg: any, ...argArray: any... |
584+
| tst.ts:439:49:439:52 | args | Args |
585+
| tst.ts:440:13:440:19 | console | Console |
586+
| tst.ts:440:13:440:23 | console.log | (...data: any[]) => void |
587+
| tst.ts:440:13:440:63 | console ... me}'.`) | void |
588+
| tst.ts:440:21:440:23 | log | (...data: any[]) => void |
589+
| tst.ts:440:25:440:62 | `LOG: E ... ame}'.` | string |
590+
| tst.ts:440:26:440:46 | LOG: Ex ... ethod ' | any |
591+
| tst.ts:440:49:440:58 | methodName | string |
592+
| tst.ts:440:60:440:61 | '. | any |
593+
| tst.ts:441:20:441:25 | result | any |
594+
| tst.ts:447:11:447:16 | Person | Person |
595+
| tst.ts:448:9:448:12 | name | string |
596+
| tst.ts:449:9:451:9 | constru ... } | any |
597+
| tst.ts:449:21:449:24 | name | string |
598+
| tst.ts:450:13:450:21 | this.name | string |
599+
| tst.ts:450:13:450:28 | this.name = name | string |
600+
| tst.ts:450:18:450:21 | name | string |
601+
| tst.ts:450:25:450:28 | name | string |
602+
| tst.ts:453:10:453:25 | loggedMethod("") | (this: unknown, args_0: () => number, args_1: C... |
603+
| tst.ts:453:23:453:24 | "" | "" |
604+
| tst.ts:454:9:454:13 | greet | () => number |
605+
| tst.ts:454:9:457:9 | greet() ... } | () => number |
606+
| tst.ts:455:13:455:19 | console | Console |
607+
| tst.ts:455:13:455:23 | console.log | (...data: any[]) => void |
608+
| tst.ts:455:13:455:58 | console ... ame}.`) | void |
609+
| tst.ts:455:21:455:23 | log | (...data: any[]) => void |
610+
| tst.ts:455:25:455:57 | `Hello, ... name}.` | string |
611+
| tst.ts:455:26:455:43 | Hello, my name is | any |
612+
| tst.ts:455:46:455:54 | this.name | string |
613+
| tst.ts:455:51:455:54 | name | string |
614+
| tst.ts:455:56:455:56 | . | any |
615+
| tst.ts:456:20:456:20 | 2 | 2 |
616+
| tst.ts:460:11:460:11 | p | number |
617+
| tst.ts:460:15:460:32 | new Person("John") | Person |
618+
| tst.ts:460:15:460:38 | new Per ... ).greet | () => number |
619+
| tst.ts:460:15:460:40 | new Per ... greet() | number |
620+
| tst.ts:460:19:460:24 | Person | typeof Person in tst.ts:430 |
621+
| tst.ts:460:26:460:31 | "John" | "John" |
622+
| tst.ts:460:34:460:38 | greet | () => number |
623+
| tst.ts:462:22:462:38 | myConstIdFunction | <const T extends readonly string[]>(args: T) => T |
624+
| tst.ts:462:75:462:78 | args | T |
625+
| tst.ts:465:11:465:13 | foo | readonly ["a", "b", "c"] |
626+
| tst.ts:465:17:465:33 | myConstIdFunction | <const T extends readonly string[]>(args: T) => T |
627+
| tst.ts:465:17:465:50 | myConst ... ,"c"]) | readonly ["a", "b", "c"] |
628+
| tst.ts:465:35:465:49 | ["a", "b" ,"c"] | readonly ["a", "b", "c"] |
629+
| tst.ts:465:36:465:38 | "a" | "a" |
630+
| tst.ts:465:41:465:43 | "b" | "b" |
631+
| tst.ts:465:46:465:48 | "c" | "c" |
632+
| tst.ts:467:11:467:11 | b | "b" |
633+
| tst.ts:467:15:467:17 | foo | readonly ["a", "b", "c"] |
634+
| tst.ts:467:15:467:20 | foo[1] | "b" |
635+
| tst.ts:467:19:467:19 | 1 | 1 |
563636
| tstModuleCJS.cts:1:17:1:28 | tstModuleCJS | () => "a" \| "b" |
564637
| tstModuleCJS.cts:2:12:2:15 | Math | Math |
565638
| tstModuleCJS.cts:2:12:2:22 | Math.random | () => number |
@@ -670,6 +743,7 @@ getTypeDefinitionType
670743
| tst.ts:404:3:406:3 | interfa ... er;\\n } | RGBObj |
671744
| tst.ts:408:3:410:3 | interfa ... er;\\n } | HSVObj |
672745
| tst.ts:419:3:425:3 | class P ... }\\n } | Person |
746+
| tst.ts:447:5:458:5 | class P ... }\\n } | Person |
673747
| type_alias.ts:1:1:1:17 | type B = boolean; | boolean |
674748
| type_alias.ts:5:1:5:50 | type Va ... ay<T>>; | ValueOrArray<T> |
675749
| type_alias.ts:9:1:15:13 | type Js ... Json[]; | Json |
@@ -995,6 +1069,30 @@ getTypeExprType
9951069
| tst.ts:412:37:412:42 | HSVObj | HSVObj |
9961070
| tst.ts:420:20:420:25 | string | string |
9971071
| tst.ts:422:23:422:28 | string | string |
1072+
| tst.ts:431:27:431:30 | This | This |
1073+
| tst.ts:431:33:431:36 | Args | Args |
1074+
| tst.ts:431:46:431:48 | any | any |
1075+
| tst.ts:431:46:431:50 | any[] | any[] |
1076+
| tst.ts:431:53:431:58 | Return | Return |
1077+
| tst.ts:432:24:432:27 | This | This |
1078+
| tst.ts:432:39:432:42 | Args | Args |
1079+
| tst.ts:432:48:432:53 | Return | Return |
1080+
| tst.ts:433:18:433:44 | ClassMe ... Context | ClassMethodDecoratorContext<This, Value> |
1081+
| tst.ts:433:46:433:49 | This | This |
1082+
| tst.ts:433:59:433:62 | This | This |
1083+
| tst.ts:433:74:433:77 | Args | Args |
1084+
| tst.ts:433:83:433:88 | Return | Return |
1085+
| tst.ts:437:42:437:45 | This | This |
1086+
| tst.ts:437:57:437:60 | Args | Args |
1087+
| tst.ts:437:64:437:69 | Return | Return |
1088+
| tst.ts:448:15:448:20 | string | string |
1089+
| tst.ts:449:27:449:32 | string | string |
1090+
| tst.ts:462:46:462:46 | T | T |
1091+
| tst.ts:462:56:462:72 | readonly string[] | readonly string[] |
1092+
| tst.ts:462:65:462:70 | string | string |
1093+
| tst.ts:462:65:462:72 | string[] | readonly string[] |
1094+
| tst.ts:462:81:462:81 | T | T |
1095+
| tst.ts:462:85:462:85 | T | T |
9981096
| tstModuleCJS.cts:1:33:1:35 | 'a' | "a" |
9991097
| tstModuleCJS.cts:1:33:1:41 | 'a' \| 'b' | "a" \| "b" |
10001098
| tstModuleCJS.cts:1:39:1:41 | 'b' | "b" |
@@ -1100,6 +1198,7 @@ referenceDefinition
11001198
| NonAbstractDummy | tst.ts:54:1:56:1 | interfa ... mber;\\n} |
11011199
| Person | tst.ts:222:3:234:3 | class P ... }\\n } |
11021200
| Person | tst.ts:419:3:425:3 | class P ... }\\n } |
1201+
| Person | tst.ts:447:5:458:5 | class P ... }\\n } |
11031202
| RGB | tst.ts:393:3:393:56 | type RG ... umber]; |
11041203
| RGBObj | tst.ts:404:3:406:3 | interfa ... er;\\n } |
11051204
| Shape | tst.ts:140:3:142:47 | type Sh ... mber }; |
@@ -1164,6 +1263,18 @@ tupleTypes
11641263
| tst.ts:402:32:402:34 | red | [red: number, green: number, blue: number] | 0 | number | 3 | no-rest |
11651264
| tst.ts:402:32:402:34 | red | [red: number, green: number, blue: number] | 1 | number | 3 | no-rest |
11661265
| tst.ts:402:32:402:34 | red | [red: number, green: number, blue: number] | 2 | number | 3 | no-rest |
1266+
| tst.ts:465:11:465:13 | foo | readonly ["a", "b", "c"] | 0 | "a" | 3 | no-rest |
1267+
| tst.ts:465:11:465:13 | foo | readonly ["a", "b", "c"] | 1 | "b" | 3 | no-rest |
1268+
| tst.ts:465:11:465:13 | foo | readonly ["a", "b", "c"] | 2 | "c" | 3 | no-rest |
1269+
| tst.ts:465:17:465:50 | myConst ... ,"c"]) | readonly ["a", "b", "c"] | 0 | "a" | 3 | no-rest |
1270+
| tst.ts:465:17:465:50 | myConst ... ,"c"]) | readonly ["a", "b", "c"] | 1 | "b" | 3 | no-rest |
1271+
| tst.ts:465:17:465:50 | myConst ... ,"c"]) | readonly ["a", "b", "c"] | 2 | "c" | 3 | no-rest |
1272+
| tst.ts:465:35:465:49 | ["a", "b" ,"c"] | readonly ["a", "b", "c"] | 0 | "a" | 3 | no-rest |
1273+
| tst.ts:465:35:465:49 | ["a", "b" ,"c"] | readonly ["a", "b", "c"] | 1 | "b" | 3 | no-rest |
1274+
| tst.ts:465:35:465:49 | ["a", "b" ,"c"] | readonly ["a", "b", "c"] | 2 | "c" | 3 | no-rest |
1275+
| tst.ts:467:15:467:17 | foo | readonly ["a", "b", "c"] | 0 | "a" | 3 | no-rest |
1276+
| tst.ts:467:15:467:17 | foo | readonly ["a", "b", "c"] | 1 | "b" | 3 | no-rest |
1277+
| tst.ts:467:15:467:17 | foo | readonly ["a", "b", "c"] | 2 | "c" | 3 | no-rest |
11671278
unknownType
11681279
| tst.ts:40:5:40:15 | unknownType | unknown |
11691280
| tst.ts:47:8:47:8 | e | unknown |
@@ -1183,14 +1294,17 @@ unionIndex
11831294
| "NumberContents" | 0 | "NumberContents" \| "StringContents" |
11841295
| "StringContents" | 1 | "NumberContents" \| "StringContents" |
11851296
| "a" | 0 | "a" \| "b" |
1297+
| "a" | 0 | "a" \| "b" \| "c" |
11861298
| "a" | 1 | number \| "a" |
11871299
| "a" | 3 | number \| boolean \| "a" \| "b" |
11881300
| "b" | 1 | "a" \| "b" |
1301+
| "b" | 1 | "a" \| "b" \| "c" |
11891302
| "b" | 4 | number \| boolean \| "a" \| "b" |
11901303
| "bigint" | 2 | "string" \| "number" \| "bigint" \| "boolean" \| "s... |
11911304
| "blue" | 2 | "red" \| "green" \| "blue" |
11921305
| "boolean" | 2 | keyof TypeMap |
11931306
| "boolean" | 3 | "string" \| "number" \| "bigint" \| "boolean" \| "s... |
1307+
| "c" | 2 | "a" \| "b" \| "c" |
11941308
| "circle" | 0 | "circle" \| "square" |
11951309
| "function" | 7 | "string" \| "number" \| "bigint" \| "boolean" \| "s... |
11961310
| "green" | 1 | "red" \| "green" \| "blue" |
@@ -1204,6 +1318,9 @@ unionIndex
12041318
| "string" | 0 | keyof TypeMap |
12051319
| "symbol" | 4 | "string" \| "number" \| "bigint" \| "boolean" \| "s... |
12061320
| "undefined" | 5 | "string" \| "number" \| "bigint" \| "boolean" \| "s... |
1321+
| () => number | 0 | (() => number) \| (ClassMethodDecoratorContext<P... |
1322+
| () => number | 1 | void \| (() => number) |
1323+
| ClassMethodDecoratorContext<Person, () => numbe... | 1 | (() => number) \| (ClassMethodDecoratorContext<P... |
12071324
| Error | 1 | Success \| Error |
12081325
| Error | 1 | string \| Error |
12091326
| HSVObj | 1 | RGBObj \| HSVObj |
@@ -1257,6 +1374,7 @@ unionIndex
12571374
| true | 2 | string \| number \| true |
12581375
| true | 3 | string \| number \| boolean |
12591376
| true | 3 | string \| number \| boolean \| { [property: string... |
1377+
| void | 0 | void \| (() => number) |
12601378
| { [key: string]: any; } | 1 | string \| { [key: string]: any; } |
12611379
| { [key: string]: any; } | 2 | VirtualNode \| { [key: string]: any; } |
12621380
| { [property: string]: Json; } | 4 | string \| number \| boolean \| { [property: string... |

0 commit comments

Comments
 (0)