From 9ce248c829ac8b87850fe7e1e96c9a0abace27dc Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 10:52:56 +0100 Subject: [PATCH 01/13] update to TypeScript 4.5.2 --- docs/codeql/support/reusables/versions-compilers.rst | 2 +- javascript/change-notes/2021-11-23-typescript-4.5.md | 2 ++ javascript/extractor/lib/typescript/package.json | 2 +- javascript/extractor/lib/typescript/yarn.lock | 8 ++++---- .../extractor/src/com/semmle/js/extractor/Main.java | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 javascript/change-notes/2021-11-23-typescript-4.5.md diff --git a/docs/codeql/support/reusables/versions-compilers.rst b/docs/codeql/support/reusables/versions-compilers.rst index 7d864cd0bfd..ad8c2a16d2d 100644 --- a/docs/codeql/support/reusables/versions-compilers.rst +++ b/docs/codeql/support/reusables/versions-compilers.rst @@ -23,7 +23,7 @@ JavaScript,ECMAScript 2021 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhtm``, ``.xhtml``, ``.vue``, ``.hbs``, ``.ejs``, ``.njk``, ``.json``, ``.yaml``, ``.yml``, ``.raml``, ``.xml`` [6]_" Python,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9",Not applicable,``.py`` Ruby [7]_,"up to 3.02",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``" - TypeScript [8]_,"2.6-4.4",Standard TypeScript compiler,"``.ts``, ``.tsx``" + TypeScript [8]_,"2.6-4.5",Standard TypeScript compiler,"``.ts``, ``.tsx``" .. container:: footnote-group diff --git a/javascript/change-notes/2021-11-23-typescript-4.5.md b/javascript/change-notes/2021-11-23-typescript-4.5.md new file mode 100644 index 00000000000..2f20913f6fe --- /dev/null +++ b/javascript/change-notes/2021-11-23-typescript-4.5.md @@ -0,0 +1,2 @@ +lgtm,codescanning +* TypeScript 4.5 is now supported. diff --git a/javascript/extractor/lib/typescript/package.json b/javascript/extractor/lib/typescript/package.json index f191604e7c8..77f4685fd39 100644 --- a/javascript/extractor/lib/typescript/package.json +++ b/javascript/extractor/lib/typescript/package.json @@ -2,7 +2,7 @@ "name": "typescript-parser-wrapper", "private": true, "dependencies": { - "typescript": "4.4.2" + "typescript": "4.5.2" }, "scripts": { "build": "tsc --project tsconfig.json", diff --git a/javascript/extractor/lib/typescript/yarn.lock b/javascript/extractor/lib/typescript/yarn.lock index 639a32d261e..fe4bffb9f85 100644 --- a/javascript/extractor/lib/typescript/yarn.lock +++ b/javascript/extractor/lib/typescript/yarn.lock @@ -6,7 +6,7 @@ version "12.7.11" resolved node-12.7.11.tgz#be879b52031cfb5d295b047f5462d8ef1a716446 -typescript@4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86" - integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ== +typescript@4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998" + integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw== diff --git a/javascript/extractor/src/com/semmle/js/extractor/Main.java b/javascript/extractor/src/com/semmle/js/extractor/Main.java index 28b01815aaa..d53eb717e45 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/Main.java +++ b/javascript/extractor/src/com/semmle/js/extractor/Main.java @@ -43,7 +43,7 @@ public class Main { * A version identifier that should be updated every time the extractor changes in such a way that * it may produce different tuples for the same file under the same {@link ExtractorConfig}. */ - public static final String EXTRACTOR_VERSION = "2021-10-28"; + public static final String EXTRACTOR_VERSION = "2021-11-23"; public static final Pattern NEWLINE = Pattern.compile("\n"); From eef3905c468be83bbe80e1a01af5111be1db973e Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 10:53:30 +0100 Subject: [PATCH 02/13] update expected output. The TypeScript compiler now emits types in more cases --- .../TypeScript/HasUnderlyingType/HasUnderlyingType.expected | 2 ++ .../QualifiedNameResolution/ResolveTypeName.expected | 4 ++++ .../TypeScript/RegressionTests/ImportSelf/test.expected | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected b/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected index 47e57e0a242..4bc6869cbec 100644 --- a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected +++ b/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected @@ -2,5 +2,7 @@ underlyingTypeNode | foo | Bar | foo.ts:3:1:5:1 | use (instance (member Bar (member exports (module foo)))) | | foo | Bar | foo.ts:3:12:3:12 | use (instance (member Bar (member exports (module foo)))) | #select +| foo.ts:3:12:3:12 | x | foo.Bar in unknown scope | +| foo.ts:4:10:4:10 | x | foo.Bar in unknown scope | | tst.ts:8:14:8:16 | arg | Base in global scope | | tst.ts:8:14:8:16 | arg | Sub in global scope | diff --git a/javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveTypeName.expected b/javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveTypeName.expected index 836935ec2a5..008b2cbbbeb 100644 --- a/javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveTypeName.expected +++ b/javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveTypeName.expected @@ -16,8 +16,12 @@ | reexport-all-client.ts:4:9:4:14 | ns.G.C | G.C in library-tests/TypeScript/QualifiedNameResolution/namespaces.ts | | reexport-all-client.ts:5:9:5:11 | G.C | G.C in library-tests/TypeScript/QualifiedNameResolution/namespaces.ts | | reexport-all-client.ts:6:9:6:13 | G.J.C | G.J.C in library-tests/TypeScript/QualifiedNameResolution/namespaces.ts | +| reexport-all-client.ts:8:8:8:10 | D.F | D.F in unknown scope | +| reexport-all-client.ts:9:8:9:13 | ns.D.F | ns.D.F in unknown scope | | reexport-all-client.ts:11:8:11:16 | ns.Banana | Banana in library-tests/TypeScript/QualifiedNameResolution/export-class.ts | | reexport-named-client.ts:4:9:4:14 | ns.G.C | G.C in library-tests/TypeScript/QualifiedNameResolution/namespaces.ts | | reexport-named-client.ts:5:9:5:11 | G.C | G.C in library-tests/TypeScript/QualifiedNameResolution/namespaces.ts | | reexport-named-client.ts:6:9:6:13 | G.J.C | G.J.C in library-tests/TypeScript/QualifiedNameResolution/namespaces.ts | +| reexport-named-client.ts:8:8:8:10 | X.F | X.F in unknown scope | +| reexport-named-client.ts:9:8:9:13 | ns.X.F | ns.X.F in unknown scope | | reexport-named-client.ts:11:9:11:9 | Y | Banana in library-tests/TypeScript/QualifiedNameResolution/export-class.ts | diff --git a/javascript/ql/test/library-tests/TypeScript/RegressionTests/ImportSelf/test.expected b/javascript/ql/test/library-tests/TypeScript/RegressionTests/ImportSelf/test.expected index 6e38d3a0038..3da6ee7443d 100644 --- a/javascript/ql/test/library-tests/TypeScript/RegressionTests/ImportSelf/test.expected +++ b/javascript/ql/test/library-tests/TypeScript/RegressionTests/ImportSelf/test.expected @@ -1,4 +1,4 @@ | bar.ts:1:10:1:10 | A | any | | bar.ts:1:10:1:10 | A | any | | bar.ts:1:19:1:29 | "@blah/foo" | any | -| bar.ts:3:5:3:5 | x | any | +| bar.ts:3:5:3:5 | x | A | From 0e890fd7882b3403d783c7551e8e098de7126de8 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 10:57:29 +0100 Subject: [PATCH 03/13] add test for the Awaited type --- .../TypeScript/Types/printAst.expected | 132 ++++++++++++++---- .../TypeScript/Types/tests.expected | 39 ++++++ .../library-tests/TypeScript/Types/tst.ts | 11 ++ 3 files changed, 156 insertions(+), 26 deletions(-) diff --git a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected index 37df1d045b8..3496edf7b0e 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected @@ -790,17 +790,45 @@ nodes | tst.ts:189:19:189:21 | [VarRef] Foo | semmle.label | [VarRef] Foo | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | semmle.label | [DotExpr] Foo.#count | | tst.ts:189:23:189:28 | [Label] #count | semmle.label | [Label] #count | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | semmle.label | [NamespaceDeclaration] module ... er>>; } | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | semmle.order | 57 | +| tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | [VarDecl] TS45 | +| tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | +| tst.ts:197:8:197:8 | [Identifier] A | semmle.label | [Identifier] A | +| tst.ts:197:12:197:18 | [LocalTypeAccess] Awaited | semmle.label | [LocalTypeAccess] Awaited | +| tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | semmle.label | [GenericTypeExpr] Awaited ... tring>> | +| tst.ts:197:20:197:26 | [LocalTypeAccess] Promise | semmle.label | [LocalTypeAccess] Promise | +| tst.ts:197:20:197:34 | [GenericTypeExpr] Promise | semmle.label | [GenericTypeExpr] Promise | +| tst.ts:197:28:197:33 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | +| tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | +| tst.ts:200:8:200:8 | [Identifier] B | semmle.label | [Identifier] B | +| tst.ts:200:12:200:18 | [LocalTypeAccess] Awaited | semmle.label | [LocalTypeAccess] Awaited | +| tst.ts:200:12:200:44 | [GenericTypeExpr] Awaited ... mber>>> | semmle.label | [GenericTypeExpr] Awaited ... mber>>> | +| tst.ts:200:20:200:26 | [LocalTypeAccess] Promise | semmle.label | [LocalTypeAccess] Promise | +| tst.ts:200:20:200:43 | [GenericTypeExpr] Promise ... umber>> | semmle.label | [GenericTypeExpr] Promise ... umber>> | +| tst.ts:200:28:200:34 | [LocalTypeAccess] Promise | semmle.label | [LocalTypeAccess] Promise | +| tst.ts:200:28:200:42 | [GenericTypeExpr] Promise | semmle.label | [GenericTypeExpr] Promise | +| tst.ts:200:36:200:41 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | +| tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | +| tst.ts:203:8:203:8 | [Identifier] C | semmle.label | [Identifier] C | +| tst.ts:203:12:203:18 | [LocalTypeAccess] Awaited | semmle.label | [LocalTypeAccess] Awaited | +| tst.ts:203:12:203:45 | [GenericTypeExpr] Awaited ... umber>> | semmle.label | [GenericTypeExpr] Awaited ... umber>> | +| tst.ts:203:20:203:26 | [KeywordTypeExpr] boolean | semmle.label | [KeywordTypeExpr] boolean | +| tst.ts:203:20:203:44 | [UnionTypeExpr] boolean ... number> | semmle.label | [UnionTypeExpr] boolean ... number> | +| tst.ts:203:30:203:36 | [LocalTypeAccess] Promise | semmle.label | [LocalTypeAccess] Promise | +| tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | semmle.label | [GenericTypeExpr] Promise | +| tst.ts:203:38:203:43 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | -| type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 57 | +| type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 58 | | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | [Identifier] B | | type_alias.ts:1:10:1:16 | [KeywordTypeExpr] boolean | semmle.label | [KeywordTypeExpr] boolean | | type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.label | [DeclStmt] var b = ... | -| type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.order | 58 | +| type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.order | 59 | | type_alias.ts:3:5:3:5 | [VarDecl] b | semmle.label | [VarDecl] b | | type_alias.ts:3:5:3:8 | [VariableDeclarator] b: B | semmle.label | [VariableDeclarator] b: B | | type_alias.ts:3:8:3:8 | [LocalTypeAccess] B | semmle.label | [LocalTypeAccess] B | | type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | -| type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.order | 59 | +| type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.order | 60 | | type_alias.ts:5:6:5:17 | [Identifier] ValueOrArray | semmle.label | [Identifier] ValueOrArray | | type_alias.ts:5:19:5:19 | [Identifier] T | semmle.label | [Identifier] T | | type_alias.ts:5:19:5:19 | [TypeParameter] T | semmle.label | [TypeParameter] T | @@ -812,14 +840,14 @@ nodes | type_alias.ts:5:34:5:48 | [GenericTypeExpr] ValueOrArray | semmle.label | [GenericTypeExpr] ValueOrArray | | type_alias.ts:5:47:5:47 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.label | [DeclStmt] var c = ... | -| type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.order | 60 | +| type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.order | 61 | | type_alias.ts:7:5:7:5 | [VarDecl] c | semmle.label | [VarDecl] c | | type_alias.ts:7:5:7:27 | [VariableDeclarator] c: Valu ... number> | semmle.label | [VariableDeclarator] c: Valu ... number> | | type_alias.ts:7:8:7:19 | [LocalTypeAccess] ValueOrArray | semmle.label | [LocalTypeAccess] ValueOrArray | | type_alias.ts:7:8:7:27 | [GenericTypeExpr] ValueOrArray | semmle.label | [GenericTypeExpr] ValueOrArray | | type_alias.ts:7:21:7:26 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | -| type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.order | 61 | +| type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.order | 62 | | type_alias.ts:9:6:9:9 | [Identifier] Json | semmle.label | [Identifier] Json | | type_alias.ts:10:5:15:12 | [UnionTypeExpr] \| strin ... Json[] | semmle.label | [UnionTypeExpr] \| strin ... Json[] | | type_alias.ts:10:7:10:12 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | @@ -835,12 +863,12 @@ nodes | type_alias.ts:15:7:15:10 | [LocalTypeAccess] Json | semmle.label | [LocalTypeAccess] Json | | type_alias.ts:15:7:15:12 | [ArrayTypeExpr] Json[] | semmle.label | [ArrayTypeExpr] Json[] | | type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.label | [DeclStmt] var json = ... | -| type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.order | 62 | +| type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.order | 63 | | type_alias.ts:17:5:17:8 | [VarDecl] json | semmle.label | [VarDecl] json | | type_alias.ts:17:5:17:14 | [VariableDeclarator] json: Json | semmle.label | [VariableDeclarator] json: Json | | type_alias.ts:17:11:17:14 | [LocalTypeAccess] Json | semmle.label | [LocalTypeAccess] Json | | type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | -| type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.order | 63 | +| type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.order | 64 | | type_alias.ts:19:6:19:16 | [Identifier] VirtualNode | semmle.label | [Identifier] VirtualNode | | type_alias.ts:20:5:21:56 | [UnionTypeExpr] \| strin ... Node[]] | semmle.label | [UnionTypeExpr] \| strin ... Node[]] | | type_alias.ts:20:7:20:12 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | @@ -856,7 +884,7 @@ nodes | type_alias.ts:21:43:21:53 | [LocalTypeAccess] VirtualNode | semmle.label | [LocalTypeAccess] VirtualNode | | type_alias.ts:21:43:21:55 | [ArrayTypeExpr] VirtualNode[] | semmle.label | [ArrayTypeExpr] VirtualNode[] | | type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.label | [DeclStmt] const myNode = ... | -| type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.order | 64 | +| type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.order | 65 | | type_alias.ts:23:7:23:12 | [VarDecl] myNode | semmle.label | [VarDecl] myNode | | type_alias.ts:23:7:27:5 | [VariableDeclarator] myNode: ... ] ] | semmle.label | [VariableDeclarator] myNode: ... ] ] | | type_alias.ts:23:15:23:25 | [LocalTypeAccess] VirtualNode | semmle.label | [LocalTypeAccess] VirtualNode | @@ -881,12 +909,12 @@ nodes | type_alias.ts:26:23:26:36 | [Literal] "second-child" | semmle.label | [Literal] "second-child" | | type_alias.ts:26:41:26:62 | [Literal] "I'm the second child" | semmle.label | [Literal] "I'm the second child" | | type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.label | [ImportDeclaration] import ... dummy"; | -| type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 65 | +| type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 66 | | type_definition_objects.ts:1:8:1:17 | [ImportSpecifier] * as dummy | semmle.label | [ImportSpecifier] * as dummy | | type_definition_objects.ts:1:13:1:17 | [VarDecl] dummy | semmle.label | [VarDecl] dummy | | type_definition_objects.ts:1:24:1:32 | [Literal] "./dummy" | semmle.label | [Literal] "./dummy" | | type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.label | [ExportDeclaration] export class C {} | -| type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.order | 66 | +| type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.order | 67 | | type_definition_objects.ts:3:8:3:17 | [ClassDefinition,TypeDefinition] class C {} | semmle.label | [ClassDefinition,TypeDefinition] class C {} | | type_definition_objects.ts:3:14:3:14 | [VarDecl] C | semmle.label | [VarDecl] C | | type_definition_objects.ts:3:16:3:15 | [BlockStmt] {} | semmle.label | [BlockStmt] {} | @@ -894,36 +922,36 @@ nodes | type_definition_objects.ts:3:16:3:15 | [FunctionExpr] () {} | semmle.label | [FunctionExpr] () {} | | type_definition_objects.ts:3:16:3:15 | [Label] constructor | semmle.label | [Label] constructor | | type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.label | [DeclStmt] let classObj = ... | -| type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.order | 67 | +| type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.order | 68 | | type_definition_objects.ts:4:5:4:12 | [VarDecl] classObj | semmle.label | [VarDecl] classObj | | type_definition_objects.ts:4:5:4:16 | [VariableDeclarator] classObj = C | semmle.label | [VariableDeclarator] classObj = C | | type_definition_objects.ts:4:16:4:16 | [VarRef] C | semmle.label | [VarRef] C | | type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.label | [ExportDeclaration] export enum E {} | -| type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.order | 68 | +| type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.order | 69 | | type_definition_objects.ts:6:8:6:16 | [EnumDeclaration,TypeDefinition] enum E {} | semmle.label | [EnumDeclaration,TypeDefinition] enum E {} | | type_definition_objects.ts:6:13:6:13 | [VarDecl] E | semmle.label | [VarDecl] E | | type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.label | [DeclStmt] let enumObj = ... | -| type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.order | 69 | +| type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.order | 70 | | type_definition_objects.ts:7:5:7:11 | [VarDecl] enumObj | semmle.label | [VarDecl] enumObj | | type_definition_objects.ts:7:5:7:15 | [VariableDeclarator] enumObj = E | semmle.label | [VariableDeclarator] enumObj = E | | type_definition_objects.ts:7:15:7:15 | [VarRef] E | semmle.label | [VarRef] E | | type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.label | [ExportDeclaration] export ... e N {;} | -| type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.order | 70 | +| type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.order | 71 | | type_definition_objects.ts:9:8:9:22 | [NamespaceDeclaration] namespace N {;} | semmle.label | [NamespaceDeclaration] namespace N {;} | | type_definition_objects.ts:9:18:9:18 | [VarDecl] N | semmle.label | [VarDecl] N | | type_definition_objects.ts:9:21:9:21 | [EmptyStmt] ; | semmle.label | [EmptyStmt] ; | | type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.label | [DeclStmt] let namespaceObj = ... | -| type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.order | 71 | +| type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.order | 72 | | type_definition_objects.ts:10:5:10:16 | [VarDecl] namespaceObj | semmle.label | [VarDecl] namespaceObj | | type_definition_objects.ts:10:5:10:20 | [VariableDeclarator] namespaceObj = N | semmle.label | [VariableDeclarator] namespaceObj = N | | type_definition_objects.ts:10:20:10:20 | [VarRef] N | semmle.label | [VarRef] N | | type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.label | [ImportDeclaration] import ... dummy"; | -| type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 72 | +| type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 73 | | type_definitions.ts:1:8:1:17 | [ImportSpecifier] * as dummy | semmle.label | [ImportSpecifier] * as dummy | | type_definitions.ts:1:13:1:17 | [VarDecl] dummy | semmle.label | [VarDecl] dummy | | type_definitions.ts:1:24:1:32 | [Literal] "./dummy" | semmle.label | [Literal] "./dummy" | | type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.label | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | -| type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.order | 73 | +| type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.order | 74 | | type_definitions.ts:3:11:3:11 | [Identifier] I | semmle.label | [Identifier] I | | type_definitions.ts:3:13:3:13 | [Identifier] S | semmle.label | [Identifier] S | | type_definitions.ts:3:13:3:13 | [TypeParameter] S | semmle.label | [TypeParameter] S | @@ -931,14 +959,14 @@ nodes | type_definitions.ts:4:3:4:7 | [FieldDeclaration] x: S; | semmle.label | [FieldDeclaration] x: S; | | type_definitions.ts:4:6:4:6 | [LocalTypeAccess] S | semmle.label | [LocalTypeAccess] S | | type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.label | [DeclStmt] let i = ... | -| type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.order | 74 | +| type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.order | 75 | | type_definitions.ts:6:5:6:5 | [VarDecl] i | semmle.label | [VarDecl] i | | type_definitions.ts:6:5:6:16 | [VariableDeclarator] i: I | semmle.label | [VariableDeclarator] i: I | | type_definitions.ts:6:8:6:8 | [LocalTypeAccess] I | semmle.label | [LocalTypeAccess] I | | type_definitions.ts:6:8:6:16 | [GenericTypeExpr] I | semmle.label | [GenericTypeExpr] I | | type_definitions.ts:6:10:6:15 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.label | [ClassDefinition,TypeDefinition] class C ... x: T } | -| type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.order | 75 | +| type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.order | 76 | | type_definitions.ts:8:7:8:7 | [VarDecl] C | semmle.label | [VarDecl] C | | type_definitions.ts:8:8:8:7 | [BlockStmt] {} | semmle.label | [BlockStmt] {} | | type_definitions.ts:8:8:8:7 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | semmle.label | [ClassInitializedMember,ConstructorDefinition] constructor() {} | @@ -950,14 +978,14 @@ nodes | type_definitions.ts:9:3:9:6 | [FieldDeclaration] x: T | semmle.label | [FieldDeclaration] x: T | | type_definitions.ts:9:6:9:6 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.label | [DeclStmt] let c = ... | -| type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.order | 76 | +| type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.order | 77 | | type_definitions.ts:11:5:11:5 | [VarDecl] c | semmle.label | [VarDecl] c | | type_definitions.ts:11:5:11:16 | [VariableDeclarator] c: C | semmle.label | [VariableDeclarator] c: C | | type_definitions.ts:11:8:11:8 | [LocalTypeAccess] C | semmle.label | [LocalTypeAccess] C | | type_definitions.ts:11:8:11:16 | [GenericTypeExpr] C | semmle.label | [GenericTypeExpr] C | | type_definitions.ts:11:10:11:15 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.label | [EnumDeclaration,TypeDefinition] enum Co ... blue } | -| type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.order | 77 | +| type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.order | 78 | | type_definitions.ts:13:6:13:10 | [VarDecl] Color | semmle.label | [VarDecl] Color | | type_definitions.ts:14:3:14:5 | [EnumMember,TypeDefinition] red | semmle.label | [EnumMember,TypeDefinition] red | | type_definitions.ts:14:3:14:5 | [VarDecl] red | semmle.label | [VarDecl] red | @@ -966,29 +994,29 @@ nodes | type_definitions.ts:14:15:14:18 | [EnumMember,TypeDefinition] blue | semmle.label | [EnumMember,TypeDefinition] blue | | type_definitions.ts:14:15:14:18 | [VarDecl] blue | semmle.label | [VarDecl] blue | | type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.label | [DeclStmt] let color = ... | -| type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.order | 78 | +| type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.order | 79 | | type_definitions.ts:16:5:16:9 | [VarDecl] color | semmle.label | [VarDecl] color | | type_definitions.ts:16:5:16:16 | [VariableDeclarator] color: Color | semmle.label | [VariableDeclarator] color: Color | | type_definitions.ts:16:12:16:16 | [LocalTypeAccess] Color | semmle.label | [LocalTypeAccess] Color | | type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.label | [EnumDeclaration,TypeDefinition] enum En ... ember } | -| type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.order | 79 | +| type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.order | 80 | | type_definitions.ts:18:6:18:22 | [VarDecl] EnumWithOneMember | semmle.label | [VarDecl] EnumWithOneMember | | type_definitions.ts:18:26:18:31 | [EnumMember,TypeDefinition] member | semmle.label | [EnumMember,TypeDefinition] member | | type_definitions.ts:18:26:18:31 | [VarDecl] member | semmle.label | [VarDecl] member | | type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.label | [DeclStmt] let e = ... | -| type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.order | 80 | +| type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.order | 81 | | type_definitions.ts:19:5:19:5 | [VarDecl] e | semmle.label | [VarDecl] e | | type_definitions.ts:19:5:19:24 | [VariableDeclarator] e: EnumWithOneMember | semmle.label | [VariableDeclarator] e: EnumWithOneMember | | type_definitions.ts:19:8:19:24 | [LocalTypeAccess] EnumWithOneMember | semmle.label | [LocalTypeAccess] EnumWithOneMember | | type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | -| type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.order | 81 | +| type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.order | 82 | | type_definitions.ts:21:6:21:10 | [Identifier] Alias | semmle.label | [Identifier] Alias | | type_definitions.ts:21:12:21:12 | [Identifier] T | semmle.label | [Identifier] T | | type_definitions.ts:21:12:21:12 | [TypeParameter] T | semmle.label | [TypeParameter] T | | type_definitions.ts:21:17:21:17 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_definitions.ts:21:17:21:19 | [ArrayTypeExpr] T[] | semmle.label | [ArrayTypeExpr] T[] | | type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.label | [DeclStmt] let aliasForNumberArray = ... | -| type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.order | 82 | +| type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.order | 83 | | type_definitions.ts:22:5:22:23 | [VarDecl] aliasForNumberArray | semmle.label | [VarDecl] aliasForNumberArray | | type_definitions.ts:22:5:22:38 | [VariableDeclarator] aliasFo ... number> | semmle.label | [VariableDeclarator] aliasFo ... number> | | type_definitions.ts:22:26:22:30 | [LocalTypeAccess] Alias | semmle.label | [LocalTypeAccess] Alias | @@ -2353,6 +2381,58 @@ edges | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:19:189:21 | [VarRef] Foo | semmle.order | 1 | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:23:189:28 | [Label] #count | semmle.label | 2 | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:23:189:28 | [Label] #count | semmle.order | 2 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | 1 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.order | 1 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | 2 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.order | 2 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.label | 3 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.order | 3 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.label | 4 | +| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.order | 4 | +| tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:8:197:8 | [Identifier] A | semmle.label | 1 | +| tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:8:197:8 | [Identifier] A | semmle.order | 1 | +| tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | semmle.label | 2 | +| tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | semmle.order | 2 | +| tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | tst.ts:197:12:197:18 | [LocalTypeAccess] Awaited | semmle.label | 1 | +| tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | tst.ts:197:12:197:18 | [LocalTypeAccess] Awaited | semmle.order | 1 | +| tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | tst.ts:197:20:197:34 | [GenericTypeExpr] Promise | semmle.label | 2 | +| tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | tst.ts:197:20:197:34 | [GenericTypeExpr] Promise | semmle.order | 2 | +| tst.ts:197:20:197:34 | [GenericTypeExpr] Promise | tst.ts:197:20:197:26 | [LocalTypeAccess] Promise | semmle.label | 1 | +| tst.ts:197:20:197:34 | [GenericTypeExpr] Promise | tst.ts:197:20:197:26 | [LocalTypeAccess] Promise | semmle.order | 1 | +| tst.ts:197:20:197:34 | [GenericTypeExpr] Promise | tst.ts:197:28:197:33 | [KeywordTypeExpr] string | semmle.label | 2 | +| tst.ts:197:20:197:34 | [GenericTypeExpr] Promise | tst.ts:197:28:197:33 | [KeywordTypeExpr] string | semmle.order | 2 | +| tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | tst.ts:200:8:200:8 | [Identifier] B | semmle.label | 1 | +| tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | tst.ts:200:8:200:8 | [Identifier] B | semmle.order | 1 | +| tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | tst.ts:200:12:200:44 | [GenericTypeExpr] Awaited ... mber>>> | semmle.label | 2 | +| tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | tst.ts:200:12:200:44 | [GenericTypeExpr] Awaited ... mber>>> | semmle.order | 2 | +| tst.ts:200:12:200:44 | [GenericTypeExpr] Awaited ... mber>>> | tst.ts:200:12:200:18 | [LocalTypeAccess] Awaited | semmle.label | 1 | +| tst.ts:200:12:200:44 | [GenericTypeExpr] Awaited ... mber>>> | tst.ts:200:12:200:18 | [LocalTypeAccess] Awaited | semmle.order | 1 | +| tst.ts:200:12:200:44 | [GenericTypeExpr] Awaited ... mber>>> | tst.ts:200:20:200:43 | [GenericTypeExpr] Promise ... umber>> | semmle.label | 2 | +| tst.ts:200:12:200:44 | [GenericTypeExpr] Awaited ... mber>>> | tst.ts:200:20:200:43 | [GenericTypeExpr] Promise ... umber>> | semmle.order | 2 | +| tst.ts:200:20:200:43 | [GenericTypeExpr] Promise ... umber>> | tst.ts:200:20:200:26 | [LocalTypeAccess] Promise | semmle.label | 1 | +| tst.ts:200:20:200:43 | [GenericTypeExpr] Promise ... umber>> | tst.ts:200:20:200:26 | [LocalTypeAccess] Promise | semmle.order | 1 | +| tst.ts:200:20:200:43 | [GenericTypeExpr] Promise ... umber>> | tst.ts:200:28:200:42 | [GenericTypeExpr] Promise | semmle.label | 2 | +| tst.ts:200:20:200:43 | [GenericTypeExpr] Promise ... umber>> | tst.ts:200:28:200:42 | [GenericTypeExpr] Promise | semmle.order | 2 | +| tst.ts:200:28:200:42 | [GenericTypeExpr] Promise | tst.ts:200:28:200:34 | [LocalTypeAccess] Promise | semmle.label | 1 | +| tst.ts:200:28:200:42 | [GenericTypeExpr] Promise | tst.ts:200:28:200:34 | [LocalTypeAccess] Promise | semmle.order | 1 | +| tst.ts:200:28:200:42 | [GenericTypeExpr] Promise | tst.ts:200:36:200:41 | [KeywordTypeExpr] number | semmle.label | 2 | +| tst.ts:200:28:200:42 | [GenericTypeExpr] Promise | tst.ts:200:36:200:41 | [KeywordTypeExpr] number | semmle.order | 2 | +| tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | tst.ts:203:8:203:8 | [Identifier] C | semmle.label | 1 | +| tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | tst.ts:203:8:203:8 | [Identifier] C | semmle.order | 1 | +| tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | tst.ts:203:12:203:45 | [GenericTypeExpr] Awaited ... umber>> | semmle.label | 2 | +| tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | tst.ts:203:12:203:45 | [GenericTypeExpr] Awaited ... umber>> | semmle.order | 2 | +| tst.ts:203:12:203:45 | [GenericTypeExpr] Awaited ... umber>> | tst.ts:203:12:203:18 | [LocalTypeAccess] Awaited | semmle.label | 1 | +| tst.ts:203:12:203:45 | [GenericTypeExpr] Awaited ... umber>> | tst.ts:203:12:203:18 | [LocalTypeAccess] Awaited | semmle.order | 1 | +| tst.ts:203:12:203:45 | [GenericTypeExpr] Awaited ... umber>> | tst.ts:203:20:203:44 | [UnionTypeExpr] boolean ... number> | semmle.label | 2 | +| tst.ts:203:12:203:45 | [GenericTypeExpr] Awaited ... umber>> | tst.ts:203:20:203:44 | [UnionTypeExpr] boolean ... number> | semmle.order | 2 | +| tst.ts:203:20:203:44 | [UnionTypeExpr] boolean ... number> | tst.ts:203:20:203:26 | [KeywordTypeExpr] boolean | semmle.label | 1 | +| tst.ts:203:20:203:44 | [UnionTypeExpr] boolean ... number> | tst.ts:203:20:203:26 | [KeywordTypeExpr] boolean | semmle.order | 1 | +| tst.ts:203:20:203:44 | [UnionTypeExpr] boolean ... number> | tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | semmle.label | 2 | +| tst.ts:203:20:203:44 | [UnionTypeExpr] boolean ... number> | tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | semmle.order | 2 | +| tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | tst.ts:203:30:203:36 | [LocalTypeAccess] Promise | semmle.label | 1 | +| tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | tst.ts:203:30:203:36 | [LocalTypeAccess] Promise | semmle.order | 1 | +| tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | tst.ts:203:38:203:43 | [KeywordTypeExpr] number | semmle.label | 2 | +| tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | tst.ts:203:38:203:43 | [KeywordTypeExpr] number | semmle.order | 2 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.order | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:10:1:16 | [KeywordTypeExpr] boolean | semmle.label | 2 | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected index 1d398443dec..b25ce4fca85 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected @@ -260,6 +260,7 @@ getExprType | tst.ts:189:11:189:15 | count | number | | tst.ts:189:19:189:21 | Foo | typeof Foo in tst.ts:132 | | tst.ts:189:19:189:28 | Foo.#count | number | +| tst.ts:195:8:195:11 | TS45 | any | | type_alias.ts:3:5:3:5 | b | boolean | | type_alias.ts:7:5:7:5 | c | ValueOrArray | | type_alias.ts:14:9:14:32 | [proper ... ]: Json | any | @@ -323,6 +324,9 @@ getTypeDefinitionType | tst.ts:165:5:167:5 | interfa ... ;\\n } | Foo | | tst.ts:171:5:173:5 | interfa ... ;\\n } | Data | | tst.ts:179:3:192:3 | class F ... \\n } | Foo | +| tst.ts:197:3:197:36 | type A ... ring>>; | string | +| tst.ts:200:3:200:45 | type B ... ber>>>; | number | +| tst.ts:203:3:203:46 | type C ... mber>>; | C | | type_alias.ts:1:1:1:17 | type B = boolean; | boolean | | type_alias.ts:5:1:5:50 | type Va ... ay>; | ValueOrArray | | type_alias.ts:9:1:15:13 | type Js ... Json[]; | Json | @@ -489,6 +493,28 @@ getTypeExprType | tst.ts:172:26:172:31 | symbol | symbol | | tst.ts:172:35:172:41 | boolean | boolean | | tst.ts:175:17:175:20 | Data | Data | +| tst.ts:197:8:197:8 | A | string | +| tst.ts:197:12:197:18 | Awaited | Awaited | +| tst.ts:197:12:197:35 | Awaited ... tring>> | string | +| tst.ts:197:20:197:26 | Promise | Promise | +| tst.ts:197:20:197:34 | Promise | Promise | +| tst.ts:197:28:197:33 | string | string | +| tst.ts:200:8:200:8 | B | number | +| tst.ts:200:12:200:18 | Awaited | Awaited | +| tst.ts:200:12:200:44 | Awaited ... mber>>> | number | +| tst.ts:200:20:200:26 | Promise | Promise | +| tst.ts:200:20:200:43 | Promise ... umber>> | Promise> | +| tst.ts:200:28:200:34 | Promise | Promise | +| tst.ts:200:28:200:42 | Promise | Promise | +| tst.ts:200:36:200:41 | number | number | +| tst.ts:203:8:203:8 | C | C | +| tst.ts:203:12:203:18 | Awaited | Awaited | +| tst.ts:203:12:203:45 | Awaited ... umber>> | number \| boolean | +| tst.ts:203:20:203:26 | boolean | boolean | +| tst.ts:203:20:203:44 | boolean ... number> | boolean \| Promise | +| tst.ts:203:30:203:36 | Promise | Promise | +| tst.ts:203:30:203:44 | Promise | Promise | +| tst.ts:203:38:203:43 | number | number | | type_alias.ts:1:6:1:6 | B | boolean | | type_alias.ts:1:10:1:16 | boolean | boolean | | type_alias.ts:3:8:3:8 | B | boolean | @@ -552,6 +578,7 @@ missingToString referenceDefinition | Alias | type_definitions.ts:21:1:21:20 | type Alias = T[]; | | Alias | type_definitions.ts:21:1:21:20 | type Alias = T[]; | +| C | tst.ts:203:3:203:46 | type C ... mber>>; | | C | type_definition_objects.ts:3:8:3:17 | class C {} | | C | type_definitions.ts:8:1:10:1 | class C ... x: T\\n} | | C | type_definitions.ts:8:1:10:1 | class C ... x: T\\n} | @@ -634,15 +661,25 @@ unionIndex | "symbol" | 4 | "string" \| "number" \| "bigint" \| "boolean" \| "s... | | "undefined" | 5 | "string" \| "number" \| "bigint" \| "boolean" \| "s... | | Json[] | 5 | string \| number \| boolean \| { [property: string... | +| Promise | 2 | boolean \| Promise | +| PromiseLike | 1 | TResult1 \| PromiseLike | +| PromiseLike | 1 | TResult2 \| PromiseLike | | T | 0 | T \| ValueOrArray[] | +| TResult1 | 0 | TResult1 \| PromiseLike | +| TResult1 | 0 | TResult1 \| TResult2 | +| TResult2 | 0 | TResult2 \| PromiseLike | +| TResult2 | 1 | TResult1 \| TResult2 | | ValueOrArray[] | 1 | T \| ValueOrArray[] | | ValueOrArray[] | 1 | number \| ValueOrArray[] | | [string, { [key: string]: any; }, ...VirtualNod... | 1 | VirtualNode \| { [key: string]: any; } | | [string, { [key: string]: any; }, ...VirtualNod... | 1 | string \| [string, { [key: string]: any; }, ...V... | | false | 0 | boolean | +| false | 0 | boolean \| Promise | +| false | 1 | number \| boolean | | false | 2 | string \| number \| boolean | | false | 2 | string \| number \| boolean \| { [property: string... | | number | 0 | number \| ValueOrArray[] | +| number | 0 | number \| boolean | | number | 1 | string \| number | | number | 1 | string \| number \| boolean | | number | 1 | string \| number \| boolean \| { [property: string... | @@ -657,6 +694,8 @@ unionIndex | string | 0 | string \| { [key: string]: any; } | | symbol | 1 | string \| symbol | | true | 1 | boolean | +| true | 1 | boolean \| Promise | +| true | 2 | number \| boolean | | true | 2 | string \| number \| true | | true | 3 | string \| number \| boolean | | true | 3 | string \| number \| boolean \| { [property: string... | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts index 0db050b2f49..67febca477f 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts +++ b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts @@ -190,4 +190,15 @@ module TS44 { } } +} + +module TS45 { + // A = string + type A = Awaited>; + + // B = number + type B = Awaited>>; + + // C = boolean | number + type C = Awaited>; } \ No newline at end of file From 57399b733ef128f648534fc05990975d574ba866 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 10:58:53 +0100 Subject: [PATCH 04/13] add test for String types as Discriminants --- .../TypeScript/Types/printAst.expected | 152 ++++++++++++++++-- .../TypeScript/Types/tests.expected | 30 +++- .../library-tests/TypeScript/Types/tst.ts | 17 ++ 3 files changed, 188 insertions(+), 11 deletions(-) diff --git a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected index 3496edf7b0e..2491f38c681 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected @@ -105,6 +105,7 @@ nodes | file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | | file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | | file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | +| file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | | file://:0:0:0:0 | (TypeParameters) | semmle.label | (TypeParameters) | | file://:0:0:0:0 | (TypeParameters) | semmle.label | (TypeParameters) | | file://:0:0:0:0 | (TypeParameters) | semmle.label | (TypeParameters) | @@ -790,8 +791,8 @@ nodes | tst.ts:189:19:189:21 | [VarRef] Foo | semmle.label | [VarRef] Foo | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | semmle.label | [DotExpr] Foo.#count | | tst.ts:189:23:189:28 | [Label] #count | semmle.label | [Label] #count | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | semmle.label | [NamespaceDeclaration] module ... er>>; } | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | semmle.order | 57 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | semmle.label | [NamespaceDeclaration] module ... } } } | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | semmle.order | 57 | | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | [VarDecl] TS45 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | | tst.ts:197:8:197:8 | [Identifier] A | semmle.label | [Identifier] A | @@ -818,6 +819,49 @@ nodes | tst.ts:203:30:203:36 | [LocalTypeAccess] Promise | semmle.label | [LocalTypeAccess] Promise | | tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | semmle.label | [GenericTypeExpr] Promise | | tst.ts:203:38:203:43 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | +| tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | semmle.label | [ExportDeclaration] export ... ng; } | +| tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | semmle.label | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | +| tst.ts:205:20:205:26 | [Identifier] Success | semmle.label | [Identifier] Success | +| tst.ts:206:5:206:8 | [Label] type | semmle.label | [Label] type | +| tst.ts:206:5:206:29 | [FieldDeclaration] type: ` ... ccess`; | semmle.label | [FieldDeclaration] type: ` ... ccess`; | +| tst.ts:206:11:206:28 | [TemplateLiteralTypeExpr] `${string}Success` | semmle.label | [TemplateLiteralTypeExpr] `${string}Success` | +| tst.ts:206:14:206:19 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | +| tst.ts:206:21:206:27 | [LiteralTypeExpr] Success | semmle.label | [LiteralTypeExpr] Success | +| tst.ts:207:5:207:8 | [Label] body | semmle.label | [Label] body | +| tst.ts:207:5:207:17 | [FieldDeclaration] body: string; | semmle.label | [FieldDeclaration] body: string; | +| tst.ts:207:11:207:16 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | +| tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | semmle.label | [ExportDeclaration] export ... ng; } | +| tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | semmle.label | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | +| tst.ts:210:20:210:24 | [Identifier] Error | semmle.label | [Identifier] Error | +| tst.ts:211:7:211:10 | [Label] type | semmle.label | [Label] type | +| tst.ts:211:7:211:29 | [FieldDeclaration] type: ` ... Error`; | semmle.label | [FieldDeclaration] type: ` ... Error`; | +| tst.ts:211:13:211:28 | [TemplateLiteralTypeExpr] `${string}Error` | semmle.label | [TemplateLiteralTypeExpr] `${string}Error` | +| tst.ts:211:16:211:21 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | +| tst.ts:211:23:211:27 | [LiteralTypeExpr] Error | semmle.label | [LiteralTypeExpr] Error | +| tst.ts:212:7:212:13 | [Label] message | semmle.label | [Label] message | +| tst.ts:212:7:212:22 | [FieldDeclaration] message: string; | semmle.label | [FieldDeclaration] message: string; | +| tst.ts:212:16:212:21 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | +| tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | semmle.label | [ExportDeclaration] export ... } } | +| tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | semmle.label | [FunctionDeclStmt] functio ... } } | +| tst.ts:215:19:215:25 | [VarDecl] handler | semmle.label | [VarDecl] handler | +| tst.ts:215:27:215:27 | [SimpleParameter] r | semmle.label | [SimpleParameter] r | +| tst.ts:215:30:215:36 | [LocalTypeAccess] Success | semmle.label | [LocalTypeAccess] Success | +| tst.ts:215:30:215:44 | [UnionTypeExpr] Success \| Error | semmle.label | [UnionTypeExpr] Success \| Error | +| tst.ts:215:40:215:44 | [LocalTypeAccess] Error | semmle.label | [LocalTypeAccess] Error | +| tst.ts:215:47:220:3 | [BlockStmt] { ... } } | semmle.label | [BlockStmt] { ... } } | +| tst.ts:216:7:219:7 | [IfStmt] if (r.t ... } | semmle.label | [IfStmt] if (r.t ... } | +| tst.ts:216:11:216:11 | [VarRef] r | semmle.label | [VarRef] r | +| tst.ts:216:11:216:16 | [DotExpr] r.type | semmle.label | [DotExpr] r.type | +| tst.ts:216:11:216:34 | [BinaryExpr] r.type ... uccess" | semmle.label | [BinaryExpr] r.type ... uccess" | +| tst.ts:216:13:216:16 | [Label] type | semmle.label | [Label] type | +| tst.ts:216:22:216:34 | [Literal] "HttpSuccess" | semmle.label | [Literal] "HttpSuccess" | +| tst.ts:216:37:219:7 | [BlockStmt] { ... } | semmle.label | [BlockStmt] { ... } | +| tst.ts:218:11:218:29 | [DeclStmt] let token = ... | semmle.label | [DeclStmt] let token = ... | +| tst.ts:218:15:218:19 | [VarDecl] token | semmle.label | [VarDecl] token | +| tst.ts:218:15:218:28 | [VariableDeclarator] token = r.body | semmle.label | [VariableDeclarator] token = r.body | +| tst.ts:218:23:218:23 | [VarRef] r | semmle.label | [VarRef] r | +| tst.ts:218:23:218:28 | [DotExpr] r.body | semmle.label | [DotExpr] r.body | +| tst.ts:218:25:218:28 | [Label] body | semmle.label | [Label] body | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 58 | | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | [Identifier] B | @@ -1187,6 +1231,8 @@ edges | file://:0:0:0:0 | (Parameters) | tst.ts:166:8:166:10 | [SimpleParameter] key | semmle.order | 0 | | file://:0:0:0:0 | (Parameters) | tst.ts:172:8:172:14 | [SimpleParameter] optName | semmle.label | 0 | | file://:0:0:0:0 | (Parameters) | tst.ts:172:8:172:14 | [SimpleParameter] optName | semmle.order | 0 | +| file://:0:0:0:0 | (Parameters) | tst.ts:215:27:215:27 | [SimpleParameter] r | semmle.label | 0 | +| file://:0:0:0:0 | (Parameters) | tst.ts:215:27:215:27 | [SimpleParameter] r | semmle.order | 0 | | file://:0:0:0:0 | (Parameters) | type_alias.ts:14:10:14:17 | [SimpleParameter] property | semmle.label | 0 | | file://:0:0:0:0 | (Parameters) | type_alias.ts:14:10:14:17 | [SimpleParameter] property | semmle.order | 0 | | file://:0:0:0:0 | (Parameters) | type_alias.ts:21:19:21:21 | [SimpleParameter] key | semmle.label | 0 | @@ -2381,14 +2427,20 @@ edges | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:19:189:21 | [VarRef] Foo | semmle.order | 1 | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:23:189:28 | [Label] #count | semmle.label | 2 | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:23:189:28 | [Label] #count | semmle.order | 2 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | 1 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.order | 1 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | 2 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.order | 2 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.label | 3 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.order | 3 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.label | 4 | -| tst.ts:195:1:204:1 | [NamespaceDeclaration] module ... er>>; } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.order | 4 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | 1 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.order | 1 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | 2 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.order | 2 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.label | 3 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.order | 3 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.label | 4 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.order | 4 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | semmle.label | 5 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | semmle.order | 5 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | semmle.label | 6 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | semmle.order | 6 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | semmle.label | 7 | +| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | semmle.order | 7 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:8:197:8 | [Identifier] A | semmle.label | 1 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:8:197:8 | [Identifier] A | semmle.order | 1 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | semmle.label | 2 | @@ -2433,6 +2485,86 @@ edges | tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | tst.ts:203:30:203:36 | [LocalTypeAccess] Promise | semmle.order | 1 | | tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | tst.ts:203:38:203:43 | [KeywordTypeExpr] number | semmle.label | 2 | | tst.ts:203:30:203:44 | [GenericTypeExpr] Promise | tst.ts:203:38:203:43 | [KeywordTypeExpr] number | semmle.order | 2 | +| tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | semmle.label | 1 | +| tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | semmle.order | 1 | +| tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:205:20:205:26 | [Identifier] Success | semmle.label | 1 | +| tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:205:20:205:26 | [Identifier] Success | semmle.order | 1 | +| tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:206:5:206:29 | [FieldDeclaration] type: ` ... ccess`; | semmle.label | 2 | +| tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:206:5:206:29 | [FieldDeclaration] type: ` ... ccess`; | semmle.order | 2 | +| tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:207:5:207:17 | [FieldDeclaration] body: string; | semmle.label | 3 | +| tst.ts:205:10:208:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:207:5:207:17 | [FieldDeclaration] body: string; | semmle.order | 3 | +| tst.ts:206:5:206:29 | [FieldDeclaration] type: ` ... ccess`; | tst.ts:206:5:206:8 | [Label] type | semmle.label | 1 | +| tst.ts:206:5:206:29 | [FieldDeclaration] type: ` ... ccess`; | tst.ts:206:5:206:8 | [Label] type | semmle.order | 1 | +| tst.ts:206:5:206:29 | [FieldDeclaration] type: ` ... ccess`; | tst.ts:206:11:206:28 | [TemplateLiteralTypeExpr] `${string}Success` | semmle.label | 2 | +| tst.ts:206:5:206:29 | [FieldDeclaration] type: ` ... ccess`; | tst.ts:206:11:206:28 | [TemplateLiteralTypeExpr] `${string}Success` | semmle.order | 2 | +| tst.ts:206:11:206:28 | [TemplateLiteralTypeExpr] `${string}Success` | tst.ts:206:14:206:19 | [KeywordTypeExpr] string | semmle.label | 1 | +| tst.ts:206:11:206:28 | [TemplateLiteralTypeExpr] `${string}Success` | tst.ts:206:14:206:19 | [KeywordTypeExpr] string | semmle.order | 1 | +| tst.ts:206:11:206:28 | [TemplateLiteralTypeExpr] `${string}Success` | tst.ts:206:21:206:27 | [LiteralTypeExpr] Success | semmle.label | 2 | +| tst.ts:206:11:206:28 | [TemplateLiteralTypeExpr] `${string}Success` | tst.ts:206:21:206:27 | [LiteralTypeExpr] Success | semmle.order | 2 | +| tst.ts:207:5:207:17 | [FieldDeclaration] body: string; | tst.ts:207:5:207:8 | [Label] body | semmle.label | 1 | +| tst.ts:207:5:207:17 | [FieldDeclaration] body: string; | tst.ts:207:5:207:8 | [Label] body | semmle.order | 1 | +| tst.ts:207:5:207:17 | [FieldDeclaration] body: string; | tst.ts:207:11:207:16 | [KeywordTypeExpr] string | semmle.label | 2 | +| tst.ts:207:5:207:17 | [FieldDeclaration] body: string; | tst.ts:207:11:207:16 | [KeywordTypeExpr] string | semmle.order | 2 | +| tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | semmle.label | 1 | +| tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | semmle.order | 1 | +| tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:210:20:210:24 | [Identifier] Error | semmle.label | 1 | +| tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:210:20:210:24 | [Identifier] Error | semmle.order | 1 | +| tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:211:7:211:29 | [FieldDeclaration] type: ` ... Error`; | semmle.label | 2 | +| tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:211:7:211:29 | [FieldDeclaration] type: ` ... Error`; | semmle.order | 2 | +| tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:212:7:212:22 | [FieldDeclaration] message: string; | semmle.label | 3 | +| tst.ts:210:10:213:3 | [InterfaceDeclaration,TypeDefinition] interfa ... ng; } | tst.ts:212:7:212:22 | [FieldDeclaration] message: string; | semmle.order | 3 | +| tst.ts:211:7:211:29 | [FieldDeclaration] type: ` ... Error`; | tst.ts:211:7:211:10 | [Label] type | semmle.label | 1 | +| tst.ts:211:7:211:29 | [FieldDeclaration] type: ` ... Error`; | tst.ts:211:7:211:10 | [Label] type | semmle.order | 1 | +| tst.ts:211:7:211:29 | [FieldDeclaration] type: ` ... Error`; | tst.ts:211:13:211:28 | [TemplateLiteralTypeExpr] `${string}Error` | semmle.label | 2 | +| tst.ts:211:7:211:29 | [FieldDeclaration] type: ` ... Error`; | tst.ts:211:13:211:28 | [TemplateLiteralTypeExpr] `${string}Error` | semmle.order | 2 | +| tst.ts:211:13:211:28 | [TemplateLiteralTypeExpr] `${string}Error` | tst.ts:211:16:211:21 | [KeywordTypeExpr] string | semmle.label | 1 | +| tst.ts:211:13:211:28 | [TemplateLiteralTypeExpr] `${string}Error` | tst.ts:211:16:211:21 | [KeywordTypeExpr] string | semmle.order | 1 | +| tst.ts:211:13:211:28 | [TemplateLiteralTypeExpr] `${string}Error` | tst.ts:211:23:211:27 | [LiteralTypeExpr] Error | semmle.label | 2 | +| tst.ts:211:13:211:28 | [TemplateLiteralTypeExpr] `${string}Error` | tst.ts:211:23:211:27 | [LiteralTypeExpr] Error | semmle.order | 2 | +| tst.ts:212:7:212:22 | [FieldDeclaration] message: string; | tst.ts:212:7:212:13 | [Label] message | semmle.label | 1 | +| tst.ts:212:7:212:22 | [FieldDeclaration] message: string; | tst.ts:212:7:212:13 | [Label] message | semmle.order | 1 | +| tst.ts:212:7:212:22 | [FieldDeclaration] message: string; | tst.ts:212:16:212:21 | [KeywordTypeExpr] string | semmle.label | 2 | +| tst.ts:212:7:212:22 | [FieldDeclaration] message: string; | tst.ts:212:16:212:21 | [KeywordTypeExpr] string | semmle.order | 2 | +| tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | semmle.label | 1 | +| tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | semmle.order | 1 | +| tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | file://:0:0:0:0 | (Parameters) | semmle.label | 1 | +| tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | file://:0:0:0:0 | (Parameters) | semmle.order | 1 | +| tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | tst.ts:215:19:215:25 | [VarDecl] handler | semmle.label | 0 | +| tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | tst.ts:215:19:215:25 | [VarDecl] handler | semmle.order | 0 | +| tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | tst.ts:215:47:220:3 | [BlockStmt] { ... } } | semmle.label | 5 | +| tst.ts:215:10:220:3 | [FunctionDeclStmt] functio ... } } | tst.ts:215:47:220:3 | [BlockStmt] { ... } } | semmle.order | 5 | +| tst.ts:215:27:215:27 | [SimpleParameter] r | tst.ts:215:30:215:44 | [UnionTypeExpr] Success \| Error | semmle.label | 0 | +| tst.ts:215:27:215:27 | [SimpleParameter] r | tst.ts:215:30:215:44 | [UnionTypeExpr] Success \| Error | semmle.order | 0 | +| tst.ts:215:30:215:44 | [UnionTypeExpr] Success \| Error | tst.ts:215:30:215:36 | [LocalTypeAccess] Success | semmle.label | 1 | +| tst.ts:215:30:215:44 | [UnionTypeExpr] Success \| Error | tst.ts:215:30:215:36 | [LocalTypeAccess] Success | semmle.order | 1 | +| tst.ts:215:30:215:44 | [UnionTypeExpr] Success \| Error | tst.ts:215:40:215:44 | [LocalTypeAccess] Error | semmle.label | 2 | +| tst.ts:215:30:215:44 | [UnionTypeExpr] Success \| Error | tst.ts:215:40:215:44 | [LocalTypeAccess] Error | semmle.order | 2 | +| tst.ts:215:47:220:3 | [BlockStmt] { ... } } | tst.ts:216:7:219:7 | [IfStmt] if (r.t ... } | semmle.label | 1 | +| tst.ts:215:47:220:3 | [BlockStmt] { ... } } | tst.ts:216:7:219:7 | [IfStmt] if (r.t ... } | semmle.order | 1 | +| tst.ts:216:7:219:7 | [IfStmt] if (r.t ... } | tst.ts:216:11:216:34 | [BinaryExpr] r.type ... uccess" | semmle.label | 1 | +| tst.ts:216:7:219:7 | [IfStmt] if (r.t ... } | tst.ts:216:11:216:34 | [BinaryExpr] r.type ... uccess" | semmle.order | 1 | +| tst.ts:216:7:219:7 | [IfStmt] if (r.t ... } | tst.ts:216:37:219:7 | [BlockStmt] { ... } | semmle.label | 2 | +| tst.ts:216:7:219:7 | [IfStmt] if (r.t ... } | tst.ts:216:37:219:7 | [BlockStmt] { ... } | semmle.order | 2 | +| tst.ts:216:11:216:16 | [DotExpr] r.type | tst.ts:216:11:216:11 | [VarRef] r | semmle.label | 1 | +| tst.ts:216:11:216:16 | [DotExpr] r.type | tst.ts:216:11:216:11 | [VarRef] r | semmle.order | 1 | +| tst.ts:216:11:216:16 | [DotExpr] r.type | tst.ts:216:13:216:16 | [Label] type | semmle.label | 2 | +| tst.ts:216:11:216:16 | [DotExpr] r.type | tst.ts:216:13:216:16 | [Label] type | semmle.order | 2 | +| tst.ts:216:11:216:34 | [BinaryExpr] r.type ... uccess" | tst.ts:216:11:216:16 | [DotExpr] r.type | semmle.label | 1 | +| tst.ts:216:11:216:34 | [BinaryExpr] r.type ... uccess" | tst.ts:216:11:216:16 | [DotExpr] r.type | semmle.order | 1 | +| tst.ts:216:11:216:34 | [BinaryExpr] r.type ... uccess" | tst.ts:216:22:216:34 | [Literal] "HttpSuccess" | semmle.label | 2 | +| tst.ts:216:11:216:34 | [BinaryExpr] r.type ... uccess" | tst.ts:216:22:216:34 | [Literal] "HttpSuccess" | semmle.order | 2 | +| tst.ts:216:37:219:7 | [BlockStmt] { ... } | tst.ts:218:11:218:29 | [DeclStmt] let token = ... | semmle.label | 1 | +| tst.ts:216:37:219:7 | [BlockStmt] { ... } | tst.ts:218:11:218:29 | [DeclStmt] let token = ... | semmle.order | 1 | +| tst.ts:218:11:218:29 | [DeclStmt] let token = ... | tst.ts:218:15:218:28 | [VariableDeclarator] token = r.body | semmle.label | 1 | +| tst.ts:218:11:218:29 | [DeclStmt] let token = ... | tst.ts:218:15:218:28 | [VariableDeclarator] token = r.body | semmle.order | 1 | +| tst.ts:218:15:218:28 | [VariableDeclarator] token = r.body | tst.ts:218:15:218:19 | [VarDecl] token | semmle.label | 1 | +| tst.ts:218:15:218:28 | [VariableDeclarator] token = r.body | tst.ts:218:15:218:19 | [VarDecl] token | semmle.order | 1 | +| tst.ts:218:15:218:28 | [VariableDeclarator] token = r.body | tst.ts:218:23:218:28 | [DotExpr] r.body | semmle.label | 2 | +| tst.ts:218:15:218:28 | [VariableDeclarator] token = r.body | tst.ts:218:23:218:28 | [DotExpr] r.body | semmle.order | 2 | +| tst.ts:218:23:218:28 | [DotExpr] r.body | tst.ts:218:23:218:23 | [VarRef] r | semmle.label | 1 | +| tst.ts:218:23:218:28 | [DotExpr] r.body | tst.ts:218:23:218:23 | [VarRef] r | semmle.order | 1 | +| tst.ts:218:23:218:28 | [DotExpr] r.body | tst.ts:218:25:218:28 | [Label] body | semmle.label | 2 | +| tst.ts:218:23:218:28 | [DotExpr] r.body | tst.ts:218:25:218:28 | [Label] body | semmle.order | 2 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.order | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:10:1:16 | [KeywordTypeExpr] boolean | semmle.label | 2 | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected index b25ce4fca85..1d6b614668c 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected @@ -260,7 +260,18 @@ getExprType | tst.ts:189:11:189:15 | count | number | | tst.ts:189:19:189:21 | Foo | typeof Foo in tst.ts:132 | | tst.ts:189:19:189:28 | Foo.#count | number | -| tst.ts:195:8:195:11 | TS45 | any | +| tst.ts:195:8:195:11 | TS45 | typeof TS45 in library-tests/TypeScript/Types/tst.ts | +| tst.ts:207:5:207:8 | body | string | +| tst.ts:212:7:212:13 | message | string | +| tst.ts:215:19:215:25 | handler | (r: Success \| Error) => void | +| tst.ts:215:27:215:27 | r | Success \| Error | +| tst.ts:216:11:216:11 | r | Success \| Error | +| tst.ts:216:11:216:34 | r.type ... uccess" | boolean | +| tst.ts:216:22:216:34 | "HttpSuccess" | "HttpSuccess" | +| tst.ts:218:15:218:19 | token | string | +| tst.ts:218:23:218:23 | r | Success | +| tst.ts:218:23:218:28 | r.body | string | +| tst.ts:218:25:218:28 | body | string | | type_alias.ts:3:5:3:5 | b | boolean | | type_alias.ts:7:5:7:5 | c | ValueOrArray | | type_alias.ts:14:9:14:32 | [proper ... ]: Json | any | @@ -327,6 +338,8 @@ getTypeDefinitionType | tst.ts:197:3:197:36 | type A ... ring>>; | string | | tst.ts:200:3:200:45 | type B ... ber>>>; | number | | tst.ts:203:3:203:46 | type C ... mber>>; | C | +| tst.ts:205:10:208:3 | interfa ... ng;\\n } | Success | +| tst.ts:210:10:213:3 | interfa ... ng;\\n } | Error | | type_alias.ts:1:1:1:17 | type B = boolean; | boolean | | type_alias.ts:5:1:5:50 | type Va ... ay>; | ValueOrArray | | type_alias.ts:9:1:15:13 | type Js ... Json[]; | Json | @@ -515,6 +528,17 @@ getTypeExprType | tst.ts:203:30:203:36 | Promise | Promise | | tst.ts:203:30:203:44 | Promise | Promise | | tst.ts:203:38:203:43 | number | number | +| tst.ts:205:20:205:26 | Success | Success | +| tst.ts:206:14:206:19 | string | string | +| tst.ts:206:21:206:27 | Success | any | +| tst.ts:207:11:207:16 | string | string | +| tst.ts:210:20:210:24 | Error | Error | +| tst.ts:211:16:211:21 | string | string | +| tst.ts:211:23:211:27 | Error | any | +| tst.ts:212:16:212:21 | string | string | +| tst.ts:215:30:215:36 | Success | Success | +| tst.ts:215:30:215:44 | Success \| Error | Success \| Error | +| tst.ts:215:40:215:44 | Error | Error | | type_alias.ts:1:6:1:6 | B | boolean | | type_alias.ts:1:10:1:16 | boolean | boolean | | type_alias.ts:3:8:3:8 | B | boolean | @@ -590,6 +614,7 @@ referenceDefinition | Data | tst.ts:171:5:173:5 | interfa ... ;\\n } | | E | type_definition_objects.ts:6:8:6:16 | enum E {} | | EnumWithOneMember | type_definitions.ts:18:26:18:31 | member | +| Error | tst.ts:210:10:213:3 | interfa ... ng;\\n } | | Foo | tst.ts:116:3:129:3 | class F ... }\\n } | | Foo | tst.ts:165:5:167:5 | interfa ... ;\\n } | | Foo | tst.ts:179:3:192:3 | class F ... \\n } | @@ -602,6 +627,7 @@ referenceDefinition | NonAbstractDummy | tst.ts:54:1:56:1 | interfa ... mber;\\n} | | Shape | tst.ts:140:3:142:47 | type Sh ... mber }; | | Sub | tst.ts:97:3:101:3 | class S ... }\\n } | +| Success | tst.ts:205:10:208:3 | interfa ... ng;\\n } | | Super | tst.ts:91:3:95:3 | class S ... }\\n } | | Super | tst.ts:91:3:95:3 | class S ... }\\n } | | Thing | tst.ts:78:10:88:3 | class T ... }\\n } | @@ -660,10 +686,12 @@ unionIndex | "string" | 0 | "string" \| "number" \| "bigint" \| "boolean" \| "s... | | "symbol" | 4 | "string" \| "number" \| "bigint" \| "boolean" \| "s... | | "undefined" | 5 | "string" \| "number" \| "bigint" \| "boolean" \| "s... | +| Error | 1 | Success \| Error | | Json[] | 5 | string \| number \| boolean \| { [property: string... | | Promise | 2 | boolean \| Promise | | PromiseLike | 1 | TResult1 \| PromiseLike | | PromiseLike | 1 | TResult2 \| PromiseLike | +| Success | 0 | Success \| Error | | T | 0 | T \| ValueOrArray[] | | TResult1 | 0 | TResult1 \| PromiseLike | | TResult1 | 0 | TResult1 \| TResult2 | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts index 67febca477f..62bcb776a89 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts +++ b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts @@ -201,4 +201,21 @@ module TS45 { // C = boolean | number type C = Awaited>; + + export interface Success { + type: `${string}Success`; + body: string; + } + + export interface Error { + type: `${string}Error`; + message: string; + } + + export function handler(r: Success | Error) { + if (r.type === "HttpSuccess") { + // 'r' has type 'Success' + let token = r.body; + } + } } \ No newline at end of file From d946802057be13a7d632b44b12af2b23c4bf55b2 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 12:48:55 +0100 Subject: [PATCH 05/13] add support for type-only import specifiers --- .../src/com/semmle/js/ast/ImportSpecifier.java | 16 +++++++++++++++- .../com/semmle/js/extractor/ASTExtractor.java | 3 +++ .../ts/extractor/TypeScriptASTConverter.java | 3 ++- .../ql/lib/semmle/javascript/ES2015Modules.qll | 3 +++ javascript/ql/lib/semmlecode.javascript.dbscheme | 2 +- .../ImportOwnPackage/TypeNames.expected | 14 ++++++++++++++ .../TypeScript/ImportOwnPackage/TypeNames.ql | 6 ++++++ .../TypeScript/ImportOwnPackage/bar/client.ts | 9 +++++++++ .../TypeScript/ImportOwnPackage/foo/index.ts | 4 ++++ 9 files changed, 57 insertions(+), 3 deletions(-) diff --git a/javascript/extractor/src/com/semmle/js/ast/ImportSpecifier.java b/javascript/extractor/src/com/semmle/js/ast/ImportSpecifier.java index 8ef19fb1994..e347df0158d 100644 --- a/javascript/extractor/src/com/semmle/js/ast/ImportSpecifier.java +++ b/javascript/extractor/src/com/semmle/js/ast/ImportSpecifier.java @@ -10,15 +10,25 @@ package com.semmle.js.ast; */ public class ImportSpecifier extends Expression { private final Identifier imported, local; + private final boolean isTypeOnly; public ImportSpecifier(SourceLocation loc, Identifier imported, Identifier local) { - this("ImportSpecifier", loc, imported, local); + this(loc, imported, local, false); + } + + public ImportSpecifier(SourceLocation loc, Identifier imported, Identifier local, boolean isTypeOnly) { + this("ImportSpecifier", loc, imported, local, isTypeOnly); } public ImportSpecifier(String type, SourceLocation loc, Identifier imported, Identifier local) { + this(type, loc, imported, local, false); + } + + private ImportSpecifier(String type, SourceLocation loc, Identifier imported, Identifier local, boolean isTypeOnly) { super(type, loc); this.imported = imported; this.local = local == imported ? new NodeCopier().copy(local) : local; + this.isTypeOnly = isTypeOnly; } public Identifier getImported() { @@ -33,4 +43,8 @@ public class ImportSpecifier extends Expression { public R accept(Visitor v, C c) { return v.visit(this, c); } + + public boolean hasTypeKeyword() { + return isTypeOnly; + } } diff --git a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java index 0ed7e56df30..71d66d40ed7 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java @@ -1806,6 +1806,9 @@ public class ASTExtractor { Label lbl = super.visit(nd, c); visit(nd.getImported(), lbl, 0, IdContext.LABEL); visit(nd.getLocal(), lbl, 1, c.idcontext); + if (nd.hasTypeKeyword()) { + trapwriter.addTuple("has_type_keyword", lbl); + } return lbl; } diff --git a/javascript/extractor/src/com/semmle/ts/extractor/TypeScriptASTConverter.java b/javascript/extractor/src/com/semmle/ts/extractor/TypeScriptASTConverter.java index affea7490a5..c3172a76d67 100644 --- a/javascript/extractor/src/com/semmle/ts/extractor/TypeScriptASTConverter.java +++ b/javascript/extractor/src/com/semmle/ts/extractor/TypeScriptASTConverter.java @@ -1406,7 +1406,8 @@ public class TypeScriptASTConverter { boolean hasImported = hasChild(node, "propertyName"); Identifier imported = convertChild(node, hasImported ? "propertyName" : "name"); Identifier local = convertChild(node, "name"); - return new ImportSpecifier(loc, imported, local); + boolean isTypeOnly = node.get("isTypeOnly").getAsBoolean() == true; + return new ImportSpecifier(loc, imported, local, isTypeOnly); } private Node convertImportType(JsonObject node, SourceLocation loc) throws ParseError { diff --git a/javascript/ql/lib/semmle/javascript/ES2015Modules.qll b/javascript/ql/lib/semmle/javascript/ES2015Modules.qll index b11903c2e48..4a8777d46ec 100644 --- a/javascript/ql/lib/semmle/javascript/ES2015Modules.qll +++ b/javascript/ql/lib/semmle/javascript/ES2015Modules.qll @@ -172,6 +172,9 @@ class ImportSpecifier extends Expr, @import_specifier { VarDecl getLocal() { result = getChildExpr(1) } override string getAPrimaryQlClass() { result = "ImportSpecifier" } + + /** Holds if this is declared with the `type` keyword, so only types are imported. */ + predicate isTypeOnly() { has_type_keyword(this) } } /** diff --git a/javascript/ql/lib/semmlecode.javascript.dbscheme b/javascript/ql/lib/semmlecode.javascript.dbscheme index 8320e9d13aa..839d9abe84c 100644 --- a/javascript/ql/lib/semmlecode.javascript.dbscheme +++ b/javascript/ql/lib/semmlecode.javascript.dbscheme @@ -392,7 +392,7 @@ case @expr.kind of @exportspecifier = @named_export_specifier | @export_default_specifier | @export_namespace_specifier; -@import_or_export_declaration = @import_declaration | @export_declaration; +@import_or_export_declaration = @import_declaration | @export_declaration | @import_specifier; @type_assertion = @as_type_assertion | @prefix_type_assertion; diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected index 2a460178f35..3bca461afe2 100644 --- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected +++ b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected @@ -1,8 +1,22 @@ +getTypeString +| bar/client.ts:9:23:9:27 | Inter | Inter | +| bar/client.ts:10:12:10:14 | Bar | Bar | +| foo/index.ts:2:10:2:12 | Bar | Bar | +| foo/index.ts:7:18:7:22 | Inter | Inter | +| foo/index.ts:8:10:8:12 | Bar | Bar | +importSpec +| false | bar/client.ts:1:10:1:12 | Foo | +| false | bar/client.ts:7:10:7:20 | Foo as Foo2 | +| true | bar/client.ts:7:23:7:32 | type Inter | +| true | bar/client.ts:7:35:7:42 | type Bar | +#select | bar/client.ts:3:5:3:5 | f | my-awesome-package | Foo | | bar/client.ts:3:9:3:17 | new Foo() | my-awesome-package | Foo | | bar/client.ts:4:5:4:5 | b | my-awesome-package | Bar | | bar/client.ts:4:9:4:9 | f | my-awesome-package | Foo | | bar/client.ts:4:9:4:15 | f.bar() | my-awesome-package | Bar | +| bar/client.ts:11:16:11:24 | new Foo() | my-awesome-package | Foo | +| bar/client.ts:11:16:11:30 | new Foo().bar() | my-awesome-package | Bar | | foo/index.ts:1:14:1:16 | Foo | my-awesome-package | Foo | | foo/index.ts:2:23:2:31 | new Bar() | my-awesome-package | Bar | | foo/index.ts:5:14:5:16 | Bar | my-awesome-package | Bar | diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql index 7c2729d51f9..1db3ef62aed 100644 --- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql +++ b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql @@ -1,5 +1,11 @@ import javascript +query string getTypeString(TypeExpr te) { result = te.getType().toString() } + +query ImportSpecifier importSpec(boolean typeOnly) { + if result.isTypeOnly() then typeOnly = true else typeOnly = false +} + from Expr e, string mod, string name where e.getType().(TypeReference).hasQualifiedName(mod, name) select e, mod, name diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts index 0a5f9bbeb8f..6e5d88b412e 100644 --- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts +++ b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts @@ -2,3 +2,12 @@ import { Foo } from "../foo"; let f = new Foo(); let b = f.bar(); + + +import { Foo as Foo2, type Inter, type Bar } from "../foo"; + +class Impl implements Inter { + bar(): Bar { + return new Foo().bar(); + } +} \ No newline at end of file diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts index 51459d84ba9..ee83e5fa92d 100644 --- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts +++ b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts @@ -3,3 +3,7 @@ export class Foo { } export class Bar {} + +export interface Inter { + bar(): Bar; +} \ No newline at end of file From d1a7feebc4a27dc3a49ee313ddfd22264ba558ae Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 12:53:06 +0100 Subject: [PATCH 06/13] disable import resolution on type-only import specifiers --- javascript/ql/lib/semmle/javascript/DefUse.qll | 2 +- javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll | 1 + .../dataflow/internal/InterModuleTypeInference.qll | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/javascript/ql/lib/semmle/javascript/DefUse.qll b/javascript/ql/lib/semmle/javascript/DefUse.qll index 9ef34cd3a36..6fa0b438370 100644 --- a/javascript/ql/lib/semmle/javascript/DefUse.qll +++ b/javascript/ql/lib/semmle/javascript/DefUse.qll @@ -42,7 +42,7 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) { lhs = i.getIdentifier() and rhs = i.getImportedEntity() ) or - exists(ImportSpecifier i | def = i | lhs = i.getLocal() and rhs = i) + exists(ImportSpecifier i | def = i and not i.isTypeOnly() | lhs = i.getLocal() and rhs = i) or exists(EnumMember member | def = member.getIdentifier() | lhs = def and rhs = member.getInitializer() diff --git a/javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll b/javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll index 1d5f49d6e2f..1a108c0c5c5 100644 --- a/javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll +++ b/javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll @@ -881,6 +881,7 @@ module DataFlow { ImportSpecifierAsPropRead() { astNode = imprt.getASpecifier() and + not astNode.isTypeOnly() and exists(astNode.getImportedName()) } diff --git a/javascript/ql/lib/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll b/javascript/ql/lib/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll index 8c063e69834..1662a0055b1 100644 --- a/javascript/ql/lib/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll +++ b/javascript/ql/lib/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll @@ -15,7 +15,11 @@ private import AbstractPropertiesImpl private class AnalyzedImportSpecifier extends AnalyzedVarDef, @import_specifier { ImportDeclaration id; - AnalyzedImportSpecifier() { this = id.getASpecifier() and exists(id.resolveImportedPath()) } + AnalyzedImportSpecifier() { + this = id.getASpecifier() and + exists(id.resolveImportedPath()) and + not this.(ImportSpecifier).isTypeOnly() + } override DataFlow::AnalyzedNode getRhs() { result.(AnalyzedImport).getImportSpecifier() = this } @@ -135,10 +139,12 @@ private predicate incompleteExport(ES2015Module m, string y) { */ private class AnalyzedImport extends AnalyzedPropertyRead, DataFlow::ValueNode { Module imported; + override ImportSpecifier astNode; AnalyzedImport() { exists(ImportDeclaration id | astNode = id.getASpecifier() and + not astNode.isTypeOnly() and imported = id.getImportedModule() ) } From 19bbe6d276140116ac73c6f8db7b5946b64e73ac Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Thu, 25 Nov 2021 00:14:36 +0100 Subject: [PATCH 07/13] add JavaScript support for new private fields syntax --- .../src/com/semmle/jcorn/Parser.java | 12 +- .../com/semmle/js/extractor/ASTExtractor.java | 9 +- .../output/trap/attributes.html.trap | 404 +++++++++--------- .../tests/shebang/output/trap/tst.html.trap | 4 +- .../library-tests/Classes/privateFields.js | 12 + .../test/library-tests/Classes/tests.expected | 46 ++ .../ql/test/library-tests/Classes/tests.ql | 2 + .../SyntaxError/SyntaxError.expected | 1 - .../SyntaxError/destructingPrivate.js | 2 +- 9 files changed, 291 insertions(+), 201 deletions(-) diff --git a/javascript/extractor/src/com/semmle/jcorn/Parser.java b/javascript/extractor/src/com/semmle/jcorn/Parser.java index 6250e9d8ed6..5c8c4e559db 100644 --- a/javascript/extractor/src/com/semmle/jcorn/Parser.java +++ b/javascript/extractor/src/com/semmle/jcorn/Parser.java @@ -1646,6 +1646,15 @@ public class Parser { node = new ThisExpression(new SourceLocation(this.startLoc)); this.next(); return this.finishNode(node); + } else if (this.type == TokenType.pound) { + Position startLoc = this.startLoc; + // there is only one case where this is valid, and that is "Ergonomic brand checks for Private Fields", i.e. `#name in obj`. + Identifier id = parseIdent(true); + String op = String.valueOf(this.value); + if (!op.equals("in")) { + this.unexpected(startLoc); + } + return this.parseExprOp(id, this.start, startLoc, -1, false); } else if (this.type == TokenType.name) { Position startLoc = this.startLoc; Identifier id = this.parseIdent(this.type != TokenType.name); @@ -3314,9 +3323,6 @@ public class Parser { if (pi.kind.equals("set") && node.getValue().hasRest()) this.raiseRecoverable(params.get(params.size() - 1), "Setter cannot use rest params"); } - if (pi.key instanceof Identifier && ((Identifier)pi.key).getName().startsWith("#")) { - raiseRecoverable(pi.key, "Only fields, not methods, can be declared private."); - } return node; } diff --git a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java index 71d66d40ed7..dee68f7f3a0 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java @@ -847,8 +847,15 @@ public class ASTExtractor { @Override public Label visit(BinaryExpression nd, Context c) { Label key = super.visit(nd, c); - visit(nd.getLeft(), key, 0, true); + if (nd.getOperator().equals("in") && nd.getLeft() instanceof Identifier && ((Identifier)nd.getLeft()).getName().startsWith("#")) { + // this happens with Ergonomic brand checks for Private Fields (see https://github.com/tc39/proposal-private-fields-in-in). + // it's the only case where private field identifiers are used not as a field. + visit(nd.getLeft(), key, 0, IdContext.LABEL, true); + } else { + visit(nd.getLeft(), key, 0, true); + } visit(nd.getRight(), key, 1, true); + extractRegxpFromBinop(nd, c); return key; } diff --git a/javascript/extractor/tests/generatedcode/output/trap/attributes.html.trap b/javascript/extractor/tests/generatedcode/output/trap/attributes.html.trap index cb5eb79b1ca..69857f54fde 100644 --- a/javascript/extractor/tests/generatedcode/output/trap/attributes.html.trap +++ b/javascript/extractor/tests/generatedcode/output/trap/attributes.html.trap @@ -152,241 +152,259 @@ toplevels(#20044,4) locations_default(#20045,#10000,6,16,6,16) hasLocation(#20044,#20045) #20046=* -js_parse_errors(#20046,#20044,"Error: Unexpected token","#foo") -hasLocation(#20046,#20045) -#20047=* -lines(#20047,#20044,"#foo","") -#20048=@"loc,{#10000},6,16,6,19" -locations_default(#20048,#10000,6,16,6,19) -hasLocation(#20047,#20048) +js_parse_errors(#20046,#20044,"Error: Cannot use private fields outside a class","#foo") +#20047=@"loc,{#10000},6,20,6,20" +locations_default(#20047,#10000,6,20,6,20) +hasLocation(#20046,#20047) +#20048=* +lines(#20048,#20044,"#foo","") +#20049=@"loc,{#10000},6,16,6,19" +locations_default(#20049,#10000,6,16,6,19) +hasLocation(#20048,#20049) +numlines(#20044,1,0,0) +#20050=* +js_parse_errors(#20050,#20044,"Error: Unexpected token","#foo") +hasLocation(#20050,#20045) +#20051=* +lines(#20051,#20044,"#foo","") +hasLocation(#20051,#20049) numlines(#20044,1,0,0) toplevel_parent_xml_node(#20044,#20041) -#20049=* -template_placeholder_tag_info(#20049,#20042,"{{/foo}}") -#20050=@"loc,{#10000},6,22,6,29" -locations_default(#20050,#10000,6,22,6,29) -hasLocation(#20049,#20050) +#20052=* +template_placeholder_tag_info(#20052,#20042,"{{/foo}}") +#20053=@"loc,{#10000},6,22,6,29" +locations_default(#20053,#10000,6,22,6,29) +hasLocation(#20052,#20053) scopes(#20000,0) -#20051=@"script;{#10000},6,24" -toplevels(#20051,4) -#20052=@"loc,{#10000},6,24,6,24" -locations_default(#20052,#10000,6,24,6,24) -hasLocation(#20051,#20052) -#20053=* -js_parse_errors(#20053,#20051,"Error: Unterminated regular expression","/foo") -#20054=@"loc,{#10000},6,25,6,25" -locations_default(#20054,#10000,6,25,6,25) -hasLocation(#20053,#20054) -#20055=* -lines(#20055,#20051,"/foo","") -#20056=@"loc,{#10000},6,24,6,27" -locations_default(#20056,#10000,6,24,6,27) -hasLocation(#20055,#20056) -numlines(#20051,1,0,0) -toplevel_parent_xml_node(#20051,#20049) -#20057=* +#20054=@"script;{#10000},6,24" +toplevels(#20054,4) +#20055=@"loc,{#10000},6,24,6,24" +locations_default(#20055,#10000,6,24,6,24) +hasLocation(#20054,#20055) +#20056=* +js_parse_errors(#20056,#20054,"Error: Unterminated regular expression","/foo") +#20057=@"loc,{#10000},6,25,6,25" +locations_default(#20057,#10000,6,25,6,25) +hasLocation(#20056,#20057) #20058=* -template_placeholder_tag_info(#20057,#20058,"{{#foo}}") -#20059=@"loc,{#10000},8,18,8,25" -locations_default(#20059,#10000,8,18,8,25) -hasLocation(#20057,#20059) +lines(#20058,#20054,"/foo","") +#20059=@"loc,{#10000},6,24,6,27" +locations_default(#20059,#10000,6,24,6,27) +hasLocation(#20058,#20059) +numlines(#20054,1,0,0) +toplevel_parent_xml_node(#20054,#20052) +#20060=* +#20061=* +template_placeholder_tag_info(#20060,#20061,"{{#foo}}") +#20062=@"loc,{#10000},8,18,8,25" +locations_default(#20062,#10000,8,18,8,25) +hasLocation(#20060,#20062) scopes(#20000,0) -#20060=@"script;{#10000},8,20" -toplevels(#20060,4) -#20061=@"loc,{#10000},8,20,8,20" -locations_default(#20061,#10000,8,20,8,20) -hasLocation(#20060,#20061) -#20062=* -js_parse_errors(#20062,#20060,"Error: Unexpected token","#foo") -hasLocation(#20062,#20061) -#20063=* -lines(#20063,#20060,"#foo","") -#20064=@"loc,{#10000},8,20,8,23" -locations_default(#20064,#10000,8,20,8,23) +#20063=@"script;{#10000},8,20" +toplevels(#20063,4) +#20064=@"loc,{#10000},8,20,8,20" +locations_default(#20064,#10000,8,20,8,20) hasLocation(#20063,#20064) -numlines(#20060,1,0,0) -toplevel_parent_xml_node(#20060,#20057) #20065=* -template_placeholder_tag_info(#20065,#20058,"{{baz}}") -#20066=@"loc,{#10000},8,30,8,36" -locations_default(#20066,#10000,8,30,8,36) +js_parse_errors(#20065,#20063,"Error: Cannot use private fields outside a class","#foo") +#20066=@"loc,{#10000},8,24,8,24" +locations_default(#20066,#10000,8,24,8,24) hasLocation(#20065,#20066) -scopes(#20000,0) -#20067=@"script;{#10000},8,32" -#20068=* -lines(#20068,#20067,"baz","") -#20069=@"loc,{#10000},8,32,8,34" -locations_default(#20069,#10000,8,32,8,34) -hasLocation(#20068,#20069) -numlines(#20067,1,1,0) +#20067=* +lines(#20067,#20063,"#foo","") +#20068=@"loc,{#10000},8,20,8,23" +locations_default(#20068,#10000,8,20,8,23) +hasLocation(#20067,#20068) +numlines(#20063,1,0,0) +#20069=* +js_parse_errors(#20069,#20063,"Error: Unexpected token","#foo") +hasLocation(#20069,#20064) #20070=* -tokeninfo(#20070,6,#20067,0,"baz") -hasLocation(#20070,#20069) +lines(#20070,#20063,"#foo","") +hasLocation(#20070,#20068) +numlines(#20063,1,0,0) +toplevel_parent_xml_node(#20063,#20060) #20071=* -tokeninfo(#20071,0,#20067,1,"") -#20072=@"loc,{#10000},8,35,8,34" -locations_default(#20072,#10000,8,35,8,34) +template_placeholder_tag_info(#20071,#20061,"{{baz}}") +#20072=@"loc,{#10000},8,30,8,36" +locations_default(#20072,#10000,8,30,8,36) hasLocation(#20071,#20072) -toplevels(#20067,4) -hasLocation(#20067,#20069) -#20073=@"module;{#10000},8,32" -scopes(#20073,3) -scopenodes(#20067,#20073) -scopenesting(#20073,#20000) -is_module(#20067) -#20074=* -stmts(#20074,2,#20067,0,"baz") -hasLocation(#20074,#20069) -stmt_containers(#20074,#20067) -#20075=* -exprs(#20075,79,#20074,0,"baz") -hasLocation(#20075,#20069) -enclosing_stmt(#20075,#20074) -expr_containers(#20075,#20067) -literals("baz","baz",#20075) -#20076=@"var;{baz};{#20073}" -variables(#20076,"baz",#20073) -bind(#20075,#20076) -#20077=* -entry_cfg_node(#20077,#20067) -#20078=@"loc,{#10000},8,32,8,31" -locations_default(#20078,#10000,8,32,8,31) -hasLocation(#20077,#20078) -#20079=* -exit_cfg_node(#20079,#20067) -hasLocation(#20079,#20072) -successor(#20074,#20075) -successor(#20075,#20079) -successor(#20077,#20074) -toplevel_parent_xml_node(#20067,#20065) -#20080=* -template_placeholder_tag_info(#20080,#20058,"{{/foo}}") -#20081=@"loc,{#10000},8,37,8,44" -locations_default(#20081,#10000,8,37,8,44) -hasLocation(#20080,#20081) scopes(#20000,0) -#20082=@"script;{#10000},8,39" -toplevels(#20082,4) -#20083=@"loc,{#10000},8,39,8,39" -locations_default(#20083,#10000,8,39,8,39) -hasLocation(#20082,#20083) -#20084=* -js_parse_errors(#20084,#20082,"Error: Unterminated regular expression","/foo") -#20085=@"loc,{#10000},8,40,8,40" -locations_default(#20085,#10000,8,40,8,40) -hasLocation(#20084,#20085) +#20073=@"script;{#10000},8,32" +#20074=* +lines(#20074,#20073,"baz","") +#20075=@"loc,{#10000},8,32,8,34" +locations_default(#20075,#10000,8,32,8,34) +hasLocation(#20074,#20075) +numlines(#20073,1,1,0) +#20076=* +tokeninfo(#20076,6,#20073,0,"baz") +hasLocation(#20076,#20075) +#20077=* +tokeninfo(#20077,0,#20073,1,"") +#20078=@"loc,{#10000},8,35,8,34" +locations_default(#20078,#10000,8,35,8,34) +hasLocation(#20077,#20078) +toplevels(#20073,4) +hasLocation(#20073,#20075) +#20079=@"module;{#10000},8,32" +scopes(#20079,3) +scopenodes(#20073,#20079) +scopenesting(#20079,#20000) +is_module(#20073) +#20080=* +stmts(#20080,2,#20073,0,"baz") +hasLocation(#20080,#20075) +stmt_containers(#20080,#20073) +#20081=* +exprs(#20081,79,#20080,0,"baz") +hasLocation(#20081,#20075) +enclosing_stmt(#20081,#20080) +expr_containers(#20081,#20073) +literals("baz","baz",#20081) +#20082=@"var;{baz};{#20079}" +variables(#20082,"baz",#20079) +bind(#20081,#20082) +#20083=* +entry_cfg_node(#20083,#20073) +#20084=@"loc,{#10000},8,32,8,31" +locations_default(#20084,#10000,8,32,8,31) +hasLocation(#20083,#20084) +#20085=* +exit_cfg_node(#20085,#20073) +hasLocation(#20085,#20078) +successor(#20080,#20081) +successor(#20081,#20085) +successor(#20083,#20080) +toplevel_parent_xml_node(#20073,#20071) #20086=* -lines(#20086,#20082,"/foo","") -#20087=@"loc,{#10000},8,39,8,42" -locations_default(#20087,#10000,8,39,8,42) +template_placeholder_tag_info(#20086,#20061,"{{/foo}}") +#20087=@"loc,{#10000},8,37,8,44" +locations_default(#20087,#10000,8,37,8,44) hasLocation(#20086,#20087) -numlines(#20082,1,0,0) -toplevel_parent_xml_node(#20082,#20080) -#20088=* -xmlChars(#20088," -",#10000,0,0,#10000) -#20089=@"loc,{#10000},1,16,1,16" -locations_default(#20089,#10000,1,16,1,16) -xmllocations(#20088,#20089) +scopes(#20000,0) +#20088=@"script;{#10000},8,39" +toplevels(#20088,4) +#20089=@"loc,{#10000},8,39,8,39" +locations_default(#20089,#10000,8,39,8,39) +hasLocation(#20088,#20089) #20090=* -xmlChars(#20090," -",#10000,2,0,#10000) -#20091=@"loc,{#10000},10,8,10,8" -locations_default(#20091,#10000,10,8,10,8) -xmllocations(#20090,#20091) +js_parse_errors(#20090,#20088,"Error: Unterminated regular expression","/foo") +#20091=@"loc,{#10000},8,40,8,40" +locations_default(#20091,#10000,8,40,8,40) +hasLocation(#20090,#20091) #20092=* -xmlElements(#20092,"html",#10000,1,#10000) -#20093=@"loc,{#10000},2,1,10,7" -locations_default(#20093,#10000,2,1,10,7) -xmllocations(#20092,#20093) +lines(#20092,#20088,"/foo","") +#20093=@"loc,{#10000},8,39,8,42" +locations_default(#20093,#10000,8,39,8,42) +hasLocation(#20092,#20093) +numlines(#20088,1,0,0) +toplevel_parent_xml_node(#20088,#20086) #20094=* xmlChars(#20094," - ",#20092,0,0,#10000) -#20095=@"loc,{#10000},2,7,3,2" -locations_default(#20095,#10000,2,7,3,2) +",#10000,0,0,#10000) +#20095=@"loc,{#10000},1,16,1,16" +locations_default(#20095,#10000,1,16,1,16) xmllocations(#20094,#20095) #20096=* xmlChars(#20096," -",#20092,2,0,#10000) -#20097=@"loc,{#10000},9,10,9,10" -locations_default(#20097,#10000,9,10,9,10) +",#10000,2,0,#10000) +#20097=@"loc,{#10000},10,8,10,8" +locations_default(#20097,#10000,10,8,10,8) xmllocations(#20096,#20097) #20098=* -xmlElements(#20098,"body",#20092,1,#10000) -#20099=@"loc,{#10000},3,3,9,9" -locations_default(#20099,#10000,3,3,9,9) +xmlElements(#20098,"html",#10000,1,#10000) +#20099=@"loc,{#10000},2,1,10,7" +locations_default(#20099,#10000,2,1,10,7) xmllocations(#20098,#20099) #20100=* xmlChars(#20100," - ",#20098,0,0,#10000) -#20101=@"loc,{#10000},3,9,4,4" -locations_default(#20101,#10000,3,9,4,4) + ",#20098,0,0,#10000) +#20101=@"loc,{#10000},2,7,3,2" +locations_default(#20101,#10000,2,7,3,2) xmllocations(#20100,#20101) #20102=* xmlChars(#20102," - ",#20098,2,0,#10000) -#20103=@"loc,{#10000},4,28,5,4" -locations_default(#20103,#10000,4,28,5,4) +",#20098,2,0,#10000) +#20103=@"loc,{#10000},9,10,9,10" +locations_default(#20103,#10000,9,10,9,10) xmllocations(#20102,#20103) #20104=* -xmlChars(#20104," - ",#20098,4,0,#10000) -#20105=@"loc,{#10000},5,33,6,4" -locations_default(#20105,#10000,5,33,6,4) +xmlElements(#20104,"body",#20098,1,#10000) +#20105=@"loc,{#10000},3,3,9,9" +locations_default(#20105,#10000,3,3,9,9) xmllocations(#20104,#20105) #20106=* xmlChars(#20106," - ",#20098,6,0,#10000) -#20107=@"loc,{#10000},6,32,7,4" -locations_default(#20107,#10000,6,32,7,4) + ",#20104,0,0,#10000) +#20107=@"loc,{#10000},3,9,4,4" +locations_default(#20107,#10000,3,9,4,4) xmllocations(#20106,#20107) #20108=* xmlChars(#20108," - ",#20098,8,0,#10000) -#20109=@"loc,{#10000},7,36,8,4" -locations_default(#20109,#10000,7,36,8,4) + ",#20104,2,0,#10000) +#20109=@"loc,{#10000},4,28,5,4" +locations_default(#20109,#10000,4,28,5,4) xmllocations(#20108,#20109) #20110=* xmlChars(#20110," - ",#20098,10,0,#10000) -#20111=@"loc,{#10000},8,47,9,2" -locations_default(#20111,#10000,8,47,9,2) + ",#20104,4,0,#10000) +#20111=@"loc,{#10000},5,33,6,4" +locations_default(#20111,#10000,5,33,6,4) xmllocations(#20110,#20111) -xmlElements(#20058,"div",#20098,9,#10000) -#20112=@"loc,{#10000},8,5,8,46" -locations_default(#20112,#10000,8,5,8,46) -xmllocations(#20058,#20112) -#20113=* -xmlElements(#20113,"div",#20098,7,#10000) -#20114=@"loc,{#10000},7,5,7,35" -locations_default(#20114,#10000,7,5,7,35) -xmllocations(#20113,#20114) -#20115=* -xmlElements(#20115,"div",#20098,5,#10000) -#20116=@"loc,{#10000},6,5,6,31" -locations_default(#20116,#10000,6,5,6,31) -xmllocations(#20115,#20116) -xmlAttrs(#20042,#20115,"foo","{{#foo}}{{/foo}}/",0,#10000) -#20117=@"loc,{#10000},6,10,6,30" -locations_default(#20117,#10000,6,10,6,30) -xmllocations(#20042,#20117) -#20118=* -xmlElements(#20118,"div",#20098,3,#10000) -#20119=@"loc,{#10000},5,5,5,32" -locations_default(#20119,#10000,5,5,5,32) -xmllocations(#20118,#20119) -xmlAttrs(#20018,#20118,"foo","{{{foo}}}{{/foo}}/",0,#10000) -#20120=@"loc,{#10000},5,10,5,31" -locations_default(#20120,#10000,5,10,5,31) -xmllocations(#20018,#20120) +#20112=* +xmlChars(#20112," + ",#20104,6,0,#10000) +#20113=@"loc,{#10000},6,32,7,4" +locations_default(#20113,#10000,6,32,7,4) +xmllocations(#20112,#20113) +#20114=* +xmlChars(#20114," + ",#20104,8,0,#10000) +#20115=@"loc,{#10000},7,36,8,4" +locations_default(#20115,#10000,7,36,8,4) +xmllocations(#20114,#20115) +#20116=* +xmlChars(#20116," + ",#20104,10,0,#10000) +#20117=@"loc,{#10000},8,47,9,2" +locations_default(#20117,#10000,8,47,9,2) +xmllocations(#20116,#20117) +xmlElements(#20061,"div",#20104,9,#10000) +#20118=@"loc,{#10000},8,5,8,46" +locations_default(#20118,#10000,8,5,8,46) +xmllocations(#20061,#20118) +#20119=* +xmlElements(#20119,"div",#20104,7,#10000) +#20120=@"loc,{#10000},7,5,7,35" +locations_default(#20120,#10000,7,5,7,35) +xmllocations(#20119,#20120) #20121=* -xmlElements(#20121,"div",#20098,1,#10000) -#20122=@"loc,{#10000},4,5,4,27" -locations_default(#20122,#10000,4,5,4,27) +xmlElements(#20121,"div",#20104,5,#10000) +#20122=@"loc,{#10000},6,5,6,31" +locations_default(#20122,#10000,6,5,6,31) xmllocations(#20121,#20122) -xmlAttrs(#20002,#20121,"foo","{{foo}}",0,#10000) -#20123=@"loc,{#10000},4,10,4,20" -locations_default(#20123,#10000,4,10,4,20) -xmllocations(#20002,#20123) +xmlAttrs(#20042,#20121,"foo","{{#foo}}{{/foo}}/",0,#10000) +#20123=@"loc,{#10000},6,10,6,30" +locations_default(#20123,#10000,6,10,6,30) +xmllocations(#20042,#20123) +#20124=* +xmlElements(#20124,"div",#20104,3,#10000) +#20125=@"loc,{#10000},5,5,5,32" +locations_default(#20125,#10000,5,5,5,32) +xmllocations(#20124,#20125) +xmlAttrs(#20018,#20124,"foo","{{{foo}}}{{/foo}}/",0,#10000) +#20126=@"loc,{#10000},5,10,5,31" +locations_default(#20126,#10000,5,10,5,31) +xmllocations(#20018,#20126) +#20127=* +xmlElements(#20127,"div",#20104,1,#10000) +#20128=@"loc,{#10000},4,5,4,27" +locations_default(#20128,#10000,4,5,4,27) +xmllocations(#20127,#20128) +xmlAttrs(#20002,#20127,"foo","{{foo}}",0,#10000) +#20129=@"loc,{#10000},4,10,4,20" +locations_default(#20129,#10000,4,10,4,20) +xmllocations(#20002,#20129) numlines(#10000,10,3,0) filetype(#10000,"html") diff --git a/javascript/extractor/tests/shebang/output/trap/tst.html.trap b/javascript/extractor/tests/shebang/output/trap/tst.html.trap index 8588fd8be55..82c6276d404 100644 --- a/javascript/extractor/tests/shebang/output/trap/tst.html.trap +++ b/javascript/extractor/tests/shebang/output/trap/tst.html.trap @@ -17,8 +17,8 @@ hasLocation(#20002,#20003) #20004=* js_parse_errors(#20004,#20002,"Error: Unexpected token","#!/usr/bin/node ") -#20005=@"loc,{#10000},4,1,4,1" -locations_default(#20005,#10000,4,1,4,1) +#20005=@"loc,{#10000},4,2,4,2" +locations_default(#20005,#10000,4,2,4,2) hasLocation(#20004,#20005) #20006=* lines(#20006,#20002,""," diff --git a/javascript/ql/test/library-tests/Classes/privateFields.js b/javascript/ql/test/library-tests/Classes/privateFields.js index 5f108190bc3..e8fefcc8929 100644 --- a/javascript/ql/test/library-tests/Classes/privateFields.js +++ b/javascript/ql/test/library-tests/Classes/privateFields.js @@ -24,4 +24,16 @@ class Foo { this.#privDecl(); new this.#privDecl(); } +} + +class C { + #brand; + + #method() {} + + get #getter() {} + + static isC(obj) { + return #brand in obj && #method in obj && #getter in obj; + } } \ No newline at end of file diff --git a/javascript/ql/test/library-tests/Classes/tests.expected b/javascript/ql/test/library-tests/Classes/tests.expected index 9097aafc8db..1d4cce399de 100644 --- a/javascript/ql/test/library-tests/Classes/tests.expected +++ b/javascript/ql/test/library-tests/Classes/tests.expected @@ -11,6 +11,7 @@ test_ComputedMethods test_StaticMethods | points.js:15:3:17:3 | static ... t";\\n } | | points.js:30:3:32:3 | static ... t";\\n } | +| privateFields.js:36:3:38:3 | static ... bj;\\n } | | staticConstructor.js:2:3:2:59 | static ... tor"; } | | staticInitializer.js:12:3:14:3 | static ... 5;\\n } | test_ClassDefinition_getSuperClass @@ -19,6 +20,7 @@ test_ClassDefinition_getSuperClass test_ClassNodeStaticMethod | points.js:1:1:18:1 | class P ... ;\\n }\\n} | className | points.js:15:19:17:3 | () {\\n ... t";\\n } | | points.js:20:1:33:1 | class C ... ;\\n }\\n} | className | points.js:30:19:32:3 | () {\\n ... t";\\n } | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | isC | privateFields.js:36:13:38:3 | (obj) { ... bj;\\n } | | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | constructor | staticConstructor.js:2:21:2:59 | () { re ... tor"; } | | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | bar | staticInitializer.js:12:13:14:3 | () {\\n ... 5;\\n } | test_ClassDefinitions @@ -27,6 +29,7 @@ test_ClassDefinitions | points.js:1:1:18:1 | class P ... ;\\n }\\n} | | points.js:20:1:33:1 | class C ... ;\\n }\\n} | | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | | tst.js:1:9:4:1 | class { ... */ }\\n} | @@ -34,6 +37,7 @@ test_ClassDefinitions | tst.js:11:1:14:1 | class C ... () {}\\n} | test_AccessorMethods | points.js:7:3:9:3 | get dis ... y);\\n } | +| privateFields.js:34:3:34:18 | get #getter() {} | test_Fields | dataflow.js:5:3:5:17 | #priv = source; | dataflow.js:5:3:5:7 | #priv | | fields.js:2:3:2:4 | x; | fields.js:2:3:2:3 | x | @@ -42,6 +46,7 @@ test_Fields | privateFields.js:3:2:3:12 | #if = "if"; | privateFields.js:3:2:3:4 | #if | | privateFields.js:19:2:19:13 | #privSecond; | privateFields.js:19:2:19:12 | #privSecond | | privateFields.js:21:2:21:22 | ["#publ ... "] = 6; | privateFields.js:21:3:21:16 | "#publicField" | +| privateFields.js:30:3:30:9 | #brand; | privateFields.js:30:3:30:8 | #brand | | staticInitializer.js:2:3:2:15 | static x = 1; | staticInitializer.js:2:10:2:10 | x | test_ClassDefinition_getName | dataflow.js:4:2:13:2 | class F ... \\n\\t\\t}\\n\\t} | Foo | @@ -49,6 +54,7 @@ test_ClassDefinition_getName | points.js:1:1:18:1 | class P ... ;\\n }\\n} | Point | | points.js:20:1:33:1 | class C ... ;\\n }\\n} | ColouredPoint | | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | Foo | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | C | | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | MyClass | | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | MyClass | | tst.js:1:9:4:1 | class { ... */ }\\n} | A | @@ -71,6 +77,10 @@ test_MethodDefinitions | privateFields.js:10:2:12:2 | equals( ... ecl;\\n\\t} | privateFields.js:10:2:10:7 | equals | privateFields.js:10:8:12:2 | (o) {\\n\\t ... ecl;\\n\\t} | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | | privateFields.js:14:2:17:2 | writes( ... = 5;\\n\\t} | privateFields.js:14:2:14:7 | writes | privateFields.js:14:8:17:2 | () {\\n\\t\\t ... = 5;\\n\\t} | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | | privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} | privateFields.js:23:2:23:6 | calls | privateFields.js:23:7:26:2 | () {\\n\\t\\t ... l();\\n\\t} | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | +| privateFields.js:29:9:29:8 | constructor() {} | privateFields.js:29:9:29:8 | constructor | privateFields.js:29:9:29:8 | () {} | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | +| privateFields.js:32:3:32:14 | #method() {} | privateFields.js:32:3:32:9 | #method | privateFields.js:32:10:32:14 | () {} | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | +| privateFields.js:34:3:34:18 | get #getter() {} | privateFields.js:34:7:34:13 | #getter | privateFields.js:34:14:34:18 | () {} | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | +| privateFields.js:36:3:38:3 | static ... bj;\\n } | privateFields.js:36:10:36:12 | isC | privateFields.js:36:13:38:3 | (obj) { ... bj;\\n } | privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | | staticConstructor.js:1:15:1:14 | constructor() {} | staticConstructor.js:1:15:1:14 | constructor | staticConstructor.js:1:15:1:14 | () {} | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | | staticConstructor.js:2:3:2:59 | static ... tor"; } | staticConstructor.js:2:10:2:20 | constructor | staticConstructor.js:2:21:2:59 | () { re ... tor"; } | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | | staticInitializer.js:3:3:5:3 | constru ... 2;\\n } | staticInitializer.js:3:3:3:13 | constructor | staticInitializer.js:3:14:5:3 | () {\\n ... 2;\\n } | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | @@ -106,6 +116,11 @@ test_getAMember | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:19:2:19:13 | #privSecond; | | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:21:2:21:22 | ["#publ ... "] = 6; | | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:29:9:29:8 | constructor() {} | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:30:3:30:9 | #brand; | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:32:3:32:14 | #method() {} | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:34:3:34:18 | get #getter() {} | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:36:3:38:3 | static ... bj;\\n } | | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | staticConstructor.js:1:15:1:14 | constructor() {} | | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | staticConstructor.js:2:3:2:59 | static ... tor"; } | | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:2:3:2:15 | static x = 1; | @@ -137,6 +152,10 @@ test_MethodNames | privateFields.js:10:2:12:2 | equals( ... ecl;\\n\\t} | equals | | privateFields.js:14:2:17:2 | writes( ... = 5;\\n\\t} | writes | | privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} | calls | +| privateFields.js:29:9:29:8 | constructor() {} | constructor | +| privateFields.js:32:3:32:14 | #method() {} | #method | +| privateFields.js:34:3:34:18 | get #getter() {} | #getter | +| privateFields.js:36:3:38:3 | static ... bj;\\n } | isC | | staticConstructor.js:1:15:1:14 | constructor() {} | constructor | | staticConstructor.js:2:3:2:59 | static ... tor"; } | constructor | | staticInitializer.js:3:3:5:3 | constru ... 2;\\n } | constructor | @@ -157,6 +176,7 @@ test_SyntheticConstructors | dataflow.js:4:12:4:11 | constructor() {} | | fields.js:1:9:1:8 | constructor() {} | | privateFields.js:1:11:1:10 | constructor() {} | +| privateFields.js:29:9:29:8 | constructor() {} | | staticConstructor.js:1:15:1:14 | constructor() {} | | tst.js:11:9:11:8 | constructor() {} | test_ConstructorDefinitions @@ -165,6 +185,7 @@ test_ConstructorDefinitions | points.js:2:3:5:3 | constru ... y;\\n } | | points.js:21:3:24:3 | constru ... c;\\n } | | privateFields.js:1:11:1:10 | constructor() {} | +| privateFields.js:29:9:29:8 | constructor() {} | | staticConstructor.js:1:15:1:14 | constructor() {} | | staticInitializer.js:3:3:5:3 | constru ... 2;\\n } | | tst.js:2:3:2:50 | "constr ... r. */ } | @@ -176,6 +197,7 @@ test_ClassNodeConstructor | points.js:1:1:18:1 | class P ... ;\\n }\\n} | points.js:2:14:5:3 | (x, y) ... y;\\n } | | points.js:20:1:33:1 | class C ... ;\\n }\\n} | points.js:21:14:24:3 | (x, y, ... c;\\n } | | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | privateFields.js:1:11:1:10 | () {} | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | privateFields.js:29:9:29:8 | () {} | | staticConstructor.js:1:1:3:1 | class M ... r"; }\\n} | staticConstructor.js:1:15:1:14 | () {} | | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:3:14:5:3 | () {\\n ... 2;\\n } | | tst.js:1:9:4:1 | class { ... */ }\\n} | tst.js:2:16:2:50 | () { /* ... r. */ } | @@ -190,6 +212,7 @@ test_ClassNodeInstanceMethod | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | equals | privateFields.js:10:8:12:2 | (o) {\\n\\t ... ecl;\\n\\t} | | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | reads | privateFields.js:4:7:8:2 | () {\\n\\t\\t ... #if;\\n\\t} | | privateFields.js:1:1:27:1 | class F ... );\\n\\t}\\n} | writes | privateFields.js:14:8:17:2 | () {\\n\\t\\t ... = 5;\\n\\t} | +| privateFields.js:29:1:39:1 | class C ... ;\\n }\\n} | #method | privateFields.js:32:10:32:14 | () {} | | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | foo | staticInitializer.js:9:6:11:3 | () {\\n ... 4;\\n } | | tst.js:1:9:4:1 | class { ... */ }\\n} | constructor | tst.js:3:18:3:56 | () { /* ... r. */ } | | tst.js:11:1:14:1 | class C ... () {}\\n} | m | tst.js:12:4:12:8 | () {} | @@ -240,6 +263,10 @@ getAccessModifier | privateFields.js:23:2:26:2 | calls() ... l();\\n\\t} | privateFields.js:23:2:23:6 | calls | Public | | privateFields.js:24:3:24:16 | this.#privDecl | privateFields.js:24:8:24:16 | #privDecl | Private | | privateFields.js:25:7:25:20 | this.#privDecl | privateFields.js:25:12:25:20 | #privDecl | Private | +| privateFields.js:29:9:29:8 | constructor() {} | privateFields.js:29:9:29:8 | constructor | Public | +| privateFields.js:32:3:32:14 | #method() {} | privateFields.js:32:3:32:9 | #method | Private | +| privateFields.js:34:3:34:18 | get #getter() {} | privateFields.js:34:7:34:13 | #getter | Private | +| privateFields.js:36:3:38:3 | static ... bj;\\n } | privateFields.js:36:10:36:12 | isC | Public | | staticConstructor.js:1:15:1:14 | constructor() {} | staticConstructor.js:1:15:1:14 | constructor | Public | | staticConstructor.js:2:3:2:59 | static ... tor"; } | staticConstructor.js:2:10:2:20 | constructor | Public | | staticConstructor.js:4:1:4:11 | console.log | staticConstructor.js:4:9:4:11 | log | Public | @@ -266,3 +293,22 @@ dataflow staticInitializer | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:6:10:8:3 | {\\n M ... 3;\\n } | | staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:15:10:17:3 | {\\n t ... 6;\\n } | +privateIdentifier +| dataflow.js:5:3:5:7 | #priv | +| dataflow.js:7:16:7:20 | #priv | +| privateFields.js:2:2:2:10 | #privDecl | +| privateFields.js:3:2:3:4 | #if | +| privateFields.js:5:18:5:25 | #privUse | +| privateFields.js:7:18:7:20 | #if | +| privateFields.js:11:15:11:23 | #privDecl | +| privateFields.js:11:31:11:39 | #privDecl | +| privateFields.js:15:8:15:16 | #privDecl | +| privateFields.js:19:2:19:12 | #privSecond | +| privateFields.js:24:8:24:16 | #privDecl | +| privateFields.js:25:12:25:20 | #privDecl | +| privateFields.js:30:3:30:8 | #brand | +| privateFields.js:32:3:32:9 | #method | +| privateFields.js:34:7:34:13 | #getter | +| privateFields.js:37:12:37:17 | #brand | +| privateFields.js:37:29:37:35 | #method | +| privateFields.js:37:47:37:53 | #getter | diff --git a/javascript/ql/test/library-tests/Classes/tests.ql b/javascript/ql/test/library-tests/Classes/tests.ql index 5231f51c552..cd236367152 100644 --- a/javascript/ql/test/library-tests/Classes/tests.ql +++ b/javascript/ql/test/library-tests/Classes/tests.ql @@ -74,3 +74,5 @@ query predicate dataflow(DataFlow::Node pred, DataFlow::Node succ) { } query BlockStmt staticInitializer(ClassDefinition cd) { result = cd.getAStaticInitializerBlock() } + +query Identifier privateIdentifier() { result.getName().matches("#%") } diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.expected b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.expected index ff550943b9e..7389a898d4b 100644 --- a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.expected +++ b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/SyntaxError.expected @@ -1,4 +1,3 @@ | arrows.js:1:5:1:5 | Error: Argument name clash | Error: Argument name clash | | destructingPrivate.js:4:6:4:6 | Error: Unexpected token | Error: Unexpected token | -| privateMethod.js:2:3:2:3 | Error: Only fields, not methods, can be declared private. | Error: Only fields, not methods, can be declared private. | | tst.js:2:12:2:12 | Error: Unterminated string constant | Error: Unterminated string constant | diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js index 060111d86b4..1ca86fe4aa0 100644 --- a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js +++ b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js @@ -1,6 +1,6 @@ class C { #privDecl; bar() { - {#privDecl} = this; + {#privDecl} = this; } } \ No newline at end of file From 591aeff9065ea6334cbb9c8685ad50deeaa711a4 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 12:56:47 +0100 Subject: [PATCH 08/13] add TypeScript test for new private field syntax --- .../TypeScript/Types/printAst.expected | 164 ++++++++++++++++-- .../TypeScript/Types/tests.expected | 31 ++++ .../library-tests/TypeScript/Types/tst.ts | 14 ++ 3 files changed, 193 insertions(+), 16 deletions(-) diff --git a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected index 2491f38c681..47b3d8601a2 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected @@ -106,6 +106,8 @@ nodes | file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | | file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | | file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | +| file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | +| file://:0:0:0:0 | (Parameters) | semmle.label | (Parameters) | | file://:0:0:0:0 | (TypeParameters) | semmle.label | (TypeParameters) | | file://:0:0:0:0 | (TypeParameters) | semmle.label | (TypeParameters) | | file://:0:0:0:0 | (TypeParameters) | semmle.label | (TypeParameters) | @@ -791,8 +793,8 @@ nodes | tst.ts:189:19:189:21 | [VarRef] Foo | semmle.label | [VarRef] Foo | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | semmle.label | [DotExpr] Foo.#count | | tst.ts:189:23:189:28 | [Label] #count | semmle.label | [Label] #count | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | semmle.label | [NamespaceDeclaration] module ... } } } | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | semmle.order | 57 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | semmle.label | [NamespaceDeclaration] module ... } } } | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | semmle.order | 57 | | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | [VarDecl] TS45 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | | tst.ts:197:8:197:8 | [Identifier] A | semmle.label | [Identifier] A | @@ -862,6 +864,48 @@ nodes | tst.ts:218:23:218:23 | [VarRef] r | semmle.label | [VarRef] r | | tst.ts:218:23:218:28 | [DotExpr] r.body | semmle.label | [DotExpr] r.body | | tst.ts:218:25:218:28 | [Label] body | semmle.label | [Label] body | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | semmle.label | [ClassDefinition,TypeDefinition] class P ... } } | +| tst.ts:222:9:222:14 | [VarDecl] Person | semmle.label | [VarDecl] Person | +| tst.ts:223:5:223:9 | [Label] #name | semmle.label | [Label] #name | +| tst.ts:223:5:223:18 | [FieldDeclaration] #name: string; | semmle.label | [FieldDeclaration] #name: string; | +| tst.ts:223:12:223:17 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | +| tst.ts:224:5:226:5 | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | semmle.label | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | +| tst.ts:224:5:226:5 | [FunctionExpr] constru ... ; } | semmle.label | [FunctionExpr] constru ... ; } | +| tst.ts:224:5:226:5 | [Label] constructor | semmle.label | [Label] constructor | +| tst.ts:224:17:224:20 | [SimpleParameter] name | semmle.label | [SimpleParameter] name | +| tst.ts:224:23:224:28 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | +| tst.ts:224:31:226:5 | [BlockStmt] { ... ; } | semmle.label | [BlockStmt] { ... ; } | +| tst.ts:225:9:225:12 | [ThisExpr] this | semmle.label | [ThisExpr] this | +| tst.ts:225:9:225:18 | [DotExpr] this.#name | semmle.label | [DotExpr] this.#name | +| tst.ts:225:9:225:25 | [AssignExpr] this.#name = name | semmle.label | [AssignExpr] this.#name = name | +| tst.ts:225:9:225:26 | [ExprStmt] this.#name = name; | semmle.label | [ExprStmt] this.#name = name; | +| tst.ts:225:14:225:18 | [Label] #name | semmle.label | [Label] #name | +| tst.ts:225:22:225:25 | [VarRef] name | semmle.label | [VarRef] name | +| tst.ts:228:5:228:10 | [Label] equals | semmle.label | [Label] equals | +| tst.ts:228:5:233:5 | [ClassInitializedMember,MethodDefinition] equals( ... . } | semmle.label | [ClassInitializedMember,MethodDefinition] equals( ... . } | +| tst.ts:228:5:233:5 | [FunctionExpr] equals( ... . } | semmle.label | [FunctionExpr] equals( ... . } | +| tst.ts:228:12:228:16 | [SimpleParameter] other | semmle.label | [SimpleParameter] other | +| tst.ts:228:19:228:25 | [KeywordTypeExpr] unknown | semmle.label | [KeywordTypeExpr] unknown | +| tst.ts:228:28:233:5 | [BlockStmt] { ... . } | semmle.label | [BlockStmt] { ... . } | +| tst.ts:229:9:232:39 | [ReturnStmt] return ... .#name; | semmle.label | [ReturnStmt] return ... .#name; | +| tst.ts:229:16:229:20 | [VarRef] other | semmle.label | [VarRef] other | +| tst.ts:229:16:230:37 | [BinaryExpr] other & ... object" | semmle.label | [BinaryExpr] other & ... object" | +| tst.ts:229:16:231:26 | [BinaryExpr] other & ... n other | semmle.label | [BinaryExpr] other & ... n other | +| tst.ts:229:16:232:38 | [BinaryExpr] other & ... r.#name | semmle.label | [BinaryExpr] other & ... r.#name | +| tst.ts:230:13:230:24 | [UnaryExpr] typeof other | semmle.label | [UnaryExpr] typeof other | +| tst.ts:230:13:230:37 | [BinaryExpr] typeof ... object" | semmle.label | [BinaryExpr] typeof ... object" | +| tst.ts:230:20:230:24 | [VarRef] other | semmle.label | [VarRef] other | +| tst.ts:230:30:230:37 | [Literal] "object" | semmle.label | [Literal] "object" | +| tst.ts:231:13:231:17 | [Label] #name | semmle.label | [Label] #name | +| tst.ts:231:13:231:26 | [BinaryExpr] #name in other | semmle.label | [BinaryExpr] #name in other | +| tst.ts:231:22:231:26 | [VarRef] other | semmle.label | [VarRef] other | +| tst.ts:232:13:232:16 | [ThisExpr] this | semmle.label | [ThisExpr] this | +| tst.ts:232:13:232:22 | [DotExpr] this.#name | semmle.label | [DotExpr] this.#name | +| tst.ts:232:13:232:38 | [BinaryExpr] this.#n ... r.#name | semmle.label | [BinaryExpr] this.#n ... r.#name | +| tst.ts:232:18:232:22 | [Label] #name | semmle.label | [Label] #name | +| tst.ts:232:28:232:32 | [VarRef] other | semmle.label | [VarRef] other | +| tst.ts:232:28:232:38 | [DotExpr] other.#name | semmle.label | [DotExpr] other.#name | +| tst.ts:232:34:232:38 | [Label] #name | semmle.label | [Label] #name | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 58 | | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | [Identifier] B | @@ -1233,6 +1277,10 @@ edges | file://:0:0:0:0 | (Parameters) | tst.ts:172:8:172:14 | [SimpleParameter] optName | semmle.order | 0 | | file://:0:0:0:0 | (Parameters) | tst.ts:215:27:215:27 | [SimpleParameter] r | semmle.label | 0 | | file://:0:0:0:0 | (Parameters) | tst.ts:215:27:215:27 | [SimpleParameter] r | semmle.order | 0 | +| file://:0:0:0:0 | (Parameters) | tst.ts:224:17:224:20 | [SimpleParameter] name | semmle.label | 0 | +| file://:0:0:0:0 | (Parameters) | tst.ts:224:17:224:20 | [SimpleParameter] name | semmle.order | 0 | +| file://:0:0:0:0 | (Parameters) | tst.ts:228:12:228:16 | [SimpleParameter] other | semmle.label | 0 | +| file://:0:0:0:0 | (Parameters) | tst.ts:228:12:228:16 | [SimpleParameter] other | semmle.order | 0 | | file://:0:0:0:0 | (Parameters) | type_alias.ts:14:10:14:17 | [SimpleParameter] property | semmle.label | 0 | | file://:0:0:0:0 | (Parameters) | type_alias.ts:14:10:14:17 | [SimpleParameter] property | semmle.order | 0 | | file://:0:0:0:0 | (Parameters) | type_alias.ts:21:19:21:21 | [SimpleParameter] key | semmle.label | 0 | @@ -2427,20 +2475,22 @@ edges | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:19:189:21 | [VarRef] Foo | semmle.order | 1 | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:23:189:28 | [Label] #count | semmle.label | 2 | | tst.ts:189:19:189:28 | [DotExpr] Foo.#count | tst.ts:189:23:189:28 | [Label] #count | semmle.order | 2 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | 1 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.order | 1 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | 2 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.order | 2 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.label | 3 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.order | 3 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.label | 4 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.order | 4 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | semmle.label | 5 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | semmle.order | 5 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | semmle.label | 6 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | semmle.order | 6 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | semmle.label | 7 | -| tst.ts:195:1:221:1 | [NamespaceDeclaration] module ... } } } | tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | semmle.order | 7 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.label | 1 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:195:8:195:11 | [VarDecl] TS45 | semmle.order | 1 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.label | 2 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | semmle.order | 2 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.label | 3 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:200:3:200:45 | [TypeAliasDeclaration,TypeDefinition] type B ... ber>>>; | semmle.order | 3 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.label | 4 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:203:3:203:46 | [TypeAliasDeclaration,TypeDefinition] type C ... mber>>; | semmle.order | 4 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | semmle.label | 5 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:205:3:208:3 | [ExportDeclaration] export ... ng; } | semmle.order | 5 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | semmle.label | 6 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:210:3:213:3 | [ExportDeclaration] export ... ng; } | semmle.order | 6 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | semmle.label | 7 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:215:3:220:3 | [ExportDeclaration] export ... } } | semmle.order | 7 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | semmle.label | 8 | +| tst.ts:195:1:235:1 | [NamespaceDeclaration] module ... } } } | tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | semmle.order | 8 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:8:197:8 | [Identifier] A | semmle.label | 1 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:8:197:8 | [Identifier] A | semmle.order | 1 | | tst.ts:197:3:197:36 | [TypeAliasDeclaration,TypeDefinition] type A ... ring>>; | tst.ts:197:12:197:35 | [GenericTypeExpr] Awaited ... tring>> | semmle.label | 2 | @@ -2565,6 +2615,88 @@ edges | tst.ts:218:23:218:28 | [DotExpr] r.body | tst.ts:218:23:218:23 | [VarRef] r | semmle.order | 1 | | tst.ts:218:23:218:28 | [DotExpr] r.body | tst.ts:218:25:218:28 | [Label] body | semmle.label | 2 | | tst.ts:218:23:218:28 | [DotExpr] r.body | tst.ts:218:25:218:28 | [Label] body | semmle.order | 2 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:222:9:222:14 | [VarDecl] Person | semmle.label | 1 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:222:9:222:14 | [VarDecl] Person | semmle.order | 1 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:223:5:223:18 | [FieldDeclaration] #name: string; | semmle.label | 2 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:223:5:223:18 | [FieldDeclaration] #name: string; | semmle.order | 2 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:224:5:226:5 | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | semmle.label | 3 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:224:5:226:5 | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | semmle.order | 3 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:228:5:233:5 | [ClassInitializedMember,MethodDefinition] equals( ... . } | semmle.label | 4 | +| tst.ts:222:3:234:3 | [ClassDefinition,TypeDefinition] class P ... } } | tst.ts:228:5:233:5 | [ClassInitializedMember,MethodDefinition] equals( ... . } | semmle.order | 4 | +| tst.ts:223:5:223:18 | [FieldDeclaration] #name: string; | tst.ts:223:5:223:9 | [Label] #name | semmle.label | 1 | +| tst.ts:223:5:223:18 | [FieldDeclaration] #name: string; | tst.ts:223:5:223:9 | [Label] #name | semmle.order | 1 | +| tst.ts:223:5:223:18 | [FieldDeclaration] #name: string; | tst.ts:223:12:223:17 | [KeywordTypeExpr] string | semmle.label | 2 | +| tst.ts:223:5:223:18 | [FieldDeclaration] #name: string; | tst.ts:223:12:223:17 | [KeywordTypeExpr] string | semmle.order | 2 | +| tst.ts:224:5:226:5 | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | tst.ts:224:5:226:5 | [FunctionExpr] constru ... ; } | semmle.label | 2 | +| tst.ts:224:5:226:5 | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | tst.ts:224:5:226:5 | [FunctionExpr] constru ... ; } | semmle.order | 2 | +| tst.ts:224:5:226:5 | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | tst.ts:224:5:226:5 | [Label] constructor | semmle.label | 1 | +| tst.ts:224:5:226:5 | [ClassInitializedMember,ConstructorDefinition] constru ... ; } | tst.ts:224:5:226:5 | [Label] constructor | semmle.order | 1 | +| tst.ts:224:5:226:5 | [FunctionExpr] constru ... ; } | file://:0:0:0:0 | (Parameters) | semmle.label | 1 | +| tst.ts:224:5:226:5 | [FunctionExpr] constru ... ; } | file://:0:0:0:0 | (Parameters) | semmle.order | 1 | +| tst.ts:224:5:226:5 | [FunctionExpr] constru ... ; } | tst.ts:224:31:226:5 | [BlockStmt] { ... ; } | semmle.label | 5 | +| tst.ts:224:5:226:5 | [FunctionExpr] constru ... ; } | tst.ts:224:31:226:5 | [BlockStmt] { ... ; } | semmle.order | 5 | +| tst.ts:224:17:224:20 | [SimpleParameter] name | tst.ts:224:23:224:28 | [KeywordTypeExpr] string | semmle.label | 0 | +| tst.ts:224:17:224:20 | [SimpleParameter] name | tst.ts:224:23:224:28 | [KeywordTypeExpr] string | semmle.order | 0 | +| tst.ts:224:31:226:5 | [BlockStmt] { ... ; } | tst.ts:225:9:225:26 | [ExprStmt] this.#name = name; | semmle.label | 1 | +| tst.ts:224:31:226:5 | [BlockStmt] { ... ; } | tst.ts:225:9:225:26 | [ExprStmt] this.#name = name; | semmle.order | 1 | +| tst.ts:225:9:225:18 | [DotExpr] this.#name | tst.ts:225:9:225:12 | [ThisExpr] this | semmle.label | 1 | +| tst.ts:225:9:225:18 | [DotExpr] this.#name | tst.ts:225:9:225:12 | [ThisExpr] this | semmle.order | 1 | +| tst.ts:225:9:225:18 | [DotExpr] this.#name | tst.ts:225:14:225:18 | [Label] #name | semmle.label | 2 | +| tst.ts:225:9:225:18 | [DotExpr] this.#name | tst.ts:225:14:225:18 | [Label] #name | semmle.order | 2 | +| tst.ts:225:9:225:25 | [AssignExpr] this.#name = name | tst.ts:225:9:225:18 | [DotExpr] this.#name | semmle.label | 1 | +| tst.ts:225:9:225:25 | [AssignExpr] this.#name = name | tst.ts:225:9:225:18 | [DotExpr] this.#name | semmle.order | 1 | +| tst.ts:225:9:225:25 | [AssignExpr] this.#name = name | tst.ts:225:22:225:25 | [VarRef] name | semmle.label | 2 | +| tst.ts:225:9:225:25 | [AssignExpr] this.#name = name | tst.ts:225:22:225:25 | [VarRef] name | semmle.order | 2 | +| tst.ts:225:9:225:26 | [ExprStmt] this.#name = name; | tst.ts:225:9:225:25 | [AssignExpr] this.#name = name | semmle.label | 1 | +| tst.ts:225:9:225:26 | [ExprStmt] this.#name = name; | tst.ts:225:9:225:25 | [AssignExpr] this.#name = name | semmle.order | 1 | +| tst.ts:228:5:233:5 | [ClassInitializedMember,MethodDefinition] equals( ... . } | tst.ts:228:5:228:10 | [Label] equals | semmle.label | 1 | +| tst.ts:228:5:233:5 | [ClassInitializedMember,MethodDefinition] equals( ... . } | tst.ts:228:5:228:10 | [Label] equals | semmle.order | 1 | +| tst.ts:228:5:233:5 | [ClassInitializedMember,MethodDefinition] equals( ... . } | tst.ts:228:5:233:5 | [FunctionExpr] equals( ... . } | semmle.label | 2 | +| tst.ts:228:5:233:5 | [ClassInitializedMember,MethodDefinition] equals( ... . } | tst.ts:228:5:233:5 | [FunctionExpr] equals( ... . } | semmle.order | 2 | +| tst.ts:228:5:233:5 | [FunctionExpr] equals( ... . } | file://:0:0:0:0 | (Parameters) | semmle.label | 1 | +| tst.ts:228:5:233:5 | [FunctionExpr] equals( ... . } | file://:0:0:0:0 | (Parameters) | semmle.order | 1 | +| tst.ts:228:5:233:5 | [FunctionExpr] equals( ... . } | tst.ts:228:28:233:5 | [BlockStmt] { ... . } | semmle.label | 5 | +| tst.ts:228:5:233:5 | [FunctionExpr] equals( ... . } | tst.ts:228:28:233:5 | [BlockStmt] { ... . } | semmle.order | 5 | +| tst.ts:228:12:228:16 | [SimpleParameter] other | tst.ts:228:19:228:25 | [KeywordTypeExpr] unknown | semmle.label | 0 | +| tst.ts:228:12:228:16 | [SimpleParameter] other | tst.ts:228:19:228:25 | [KeywordTypeExpr] unknown | semmle.order | 0 | +| tst.ts:228:28:233:5 | [BlockStmt] { ... . } | tst.ts:229:9:232:39 | [ReturnStmt] return ... .#name; | semmle.label | 1 | +| tst.ts:228:28:233:5 | [BlockStmt] { ... . } | tst.ts:229:9:232:39 | [ReturnStmt] return ... .#name; | semmle.order | 1 | +| tst.ts:229:9:232:39 | [ReturnStmt] return ... .#name; | tst.ts:229:16:232:38 | [BinaryExpr] other & ... r.#name | semmle.label | 1 | +| tst.ts:229:9:232:39 | [ReturnStmt] return ... .#name; | tst.ts:229:16:232:38 | [BinaryExpr] other & ... r.#name | semmle.order | 1 | +| tst.ts:229:16:230:37 | [BinaryExpr] other & ... object" | tst.ts:229:16:229:20 | [VarRef] other | semmle.label | 1 | +| tst.ts:229:16:230:37 | [BinaryExpr] other & ... object" | tst.ts:229:16:229:20 | [VarRef] other | semmle.order | 1 | +| tst.ts:229:16:230:37 | [BinaryExpr] other & ... object" | tst.ts:230:13:230:37 | [BinaryExpr] typeof ... object" | semmle.label | 2 | +| tst.ts:229:16:230:37 | [BinaryExpr] other & ... object" | tst.ts:230:13:230:37 | [BinaryExpr] typeof ... object" | semmle.order | 2 | +| tst.ts:229:16:231:26 | [BinaryExpr] other & ... n other | tst.ts:229:16:230:37 | [BinaryExpr] other & ... object" | semmle.label | 1 | +| tst.ts:229:16:231:26 | [BinaryExpr] other & ... n other | tst.ts:229:16:230:37 | [BinaryExpr] other & ... object" | semmle.order | 1 | +| tst.ts:229:16:231:26 | [BinaryExpr] other & ... n other | tst.ts:231:13:231:26 | [BinaryExpr] #name in other | semmle.label | 2 | +| tst.ts:229:16:231:26 | [BinaryExpr] other & ... n other | tst.ts:231:13:231:26 | [BinaryExpr] #name in other | semmle.order | 2 | +| tst.ts:229:16:232:38 | [BinaryExpr] other & ... r.#name | tst.ts:229:16:231:26 | [BinaryExpr] other & ... n other | semmle.label | 1 | +| tst.ts:229:16:232:38 | [BinaryExpr] other & ... r.#name | tst.ts:229:16:231:26 | [BinaryExpr] other & ... n other | semmle.order | 1 | +| tst.ts:229:16:232:38 | [BinaryExpr] other & ... r.#name | tst.ts:232:13:232:38 | [BinaryExpr] this.#n ... r.#name | semmle.label | 2 | +| tst.ts:229:16:232:38 | [BinaryExpr] other & ... r.#name | tst.ts:232:13:232:38 | [BinaryExpr] this.#n ... r.#name | semmle.order | 2 | +| tst.ts:230:13:230:24 | [UnaryExpr] typeof other | tst.ts:230:20:230:24 | [VarRef] other | semmle.label | 1 | +| tst.ts:230:13:230:24 | [UnaryExpr] typeof other | tst.ts:230:20:230:24 | [VarRef] other | semmle.order | 1 | +| tst.ts:230:13:230:37 | [BinaryExpr] typeof ... object" | tst.ts:230:13:230:24 | [UnaryExpr] typeof other | semmle.label | 1 | +| tst.ts:230:13:230:37 | [BinaryExpr] typeof ... object" | tst.ts:230:13:230:24 | [UnaryExpr] typeof other | semmle.order | 1 | +| tst.ts:230:13:230:37 | [BinaryExpr] typeof ... object" | tst.ts:230:30:230:37 | [Literal] "object" | semmle.label | 2 | +| tst.ts:230:13:230:37 | [BinaryExpr] typeof ... object" | tst.ts:230:30:230:37 | [Literal] "object" | semmle.order | 2 | +| tst.ts:231:13:231:26 | [BinaryExpr] #name in other | tst.ts:231:13:231:17 | [Label] #name | semmle.label | 1 | +| tst.ts:231:13:231:26 | [BinaryExpr] #name in other | tst.ts:231:13:231:17 | [Label] #name | semmle.order | 1 | +| tst.ts:231:13:231:26 | [BinaryExpr] #name in other | tst.ts:231:22:231:26 | [VarRef] other | semmle.label | 2 | +| tst.ts:231:13:231:26 | [BinaryExpr] #name in other | tst.ts:231:22:231:26 | [VarRef] other | semmle.order | 2 | +| tst.ts:232:13:232:22 | [DotExpr] this.#name | tst.ts:232:13:232:16 | [ThisExpr] this | semmle.label | 1 | +| tst.ts:232:13:232:22 | [DotExpr] this.#name | tst.ts:232:13:232:16 | [ThisExpr] this | semmle.order | 1 | +| tst.ts:232:13:232:22 | [DotExpr] this.#name | tst.ts:232:18:232:22 | [Label] #name | semmle.label | 2 | +| tst.ts:232:13:232:22 | [DotExpr] this.#name | tst.ts:232:18:232:22 | [Label] #name | semmle.order | 2 | +| tst.ts:232:13:232:38 | [BinaryExpr] this.#n ... r.#name | tst.ts:232:13:232:22 | [DotExpr] this.#name | semmle.label | 1 | +| tst.ts:232:13:232:38 | [BinaryExpr] this.#n ... r.#name | tst.ts:232:13:232:22 | [DotExpr] this.#name | semmle.order | 1 | +| tst.ts:232:13:232:38 | [BinaryExpr] this.#n ... r.#name | tst.ts:232:28:232:38 | [DotExpr] other.#name | semmle.label | 2 | +| tst.ts:232:13:232:38 | [BinaryExpr] this.#n ... r.#name | tst.ts:232:28:232:38 | [DotExpr] other.#name | semmle.order | 2 | +| tst.ts:232:28:232:38 | [DotExpr] other.#name | tst.ts:232:28:232:32 | [VarRef] other | semmle.label | 1 | +| tst.ts:232:28:232:38 | [DotExpr] other.#name | tst.ts:232:28:232:32 | [VarRef] other | semmle.order | 1 | +| tst.ts:232:28:232:38 | [DotExpr] other.#name | tst.ts:232:34:232:38 | [Label] #name | semmle.label | 2 | +| tst.ts:232:28:232:38 | [DotExpr] other.#name | tst.ts:232:34:232:38 | [Label] #name | semmle.order | 2 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.order | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:10:1:16 | [KeywordTypeExpr] boolean | semmle.label | 2 | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected index 1d6b614668c..1bc82e8a02b 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected @@ -272,6 +272,29 @@ getExprType | tst.ts:218:23:218:23 | r | Success | | tst.ts:218:23:218:28 | r.body | string | | tst.ts:218:25:218:28 | body | string | +| tst.ts:222:9:222:14 | Person | Person | +| tst.ts:224:5:226:5 | constru ... ;\\n } | any | +| tst.ts:224:17:224:20 | name | string | +| tst.ts:225:9:225:18 | this.#name | string | +| tst.ts:225:9:225:25 | this.#name = name | string | +| tst.ts:225:22:225:25 | name | string | +| tst.ts:228:5:228:10 | equals | (other: unknown) => boolean | +| tst.ts:228:5:233:5 | equals( ... .\\n } | (other: unknown) => boolean | +| tst.ts:228:12:228:16 | other | unknown | +| tst.ts:229:16:229:20 | other | unknown | +| tst.ts:229:16:230:37 | other & ... object" | boolean | +| tst.ts:229:16:231:26 | other & ... n other | boolean | +| tst.ts:229:16:232:38 | other & ... r.#name | boolean | +| tst.ts:230:13:230:24 | typeof other | "string" \| "number" \| "bigint" \| "boolean" \| "s... | +| tst.ts:230:13:230:37 | typeof ... object" | boolean | +| tst.ts:230:20:230:24 | other | unknown | +| tst.ts:230:30:230:37 | "object" | "object" | +| tst.ts:231:13:231:26 | #name in other | boolean | +| tst.ts:231:22:231:26 | other | object | +| tst.ts:232:13:232:22 | this.#name | string | +| tst.ts:232:13:232:38 | this.#n ... r.#name | boolean | +| tst.ts:232:28:232:32 | other | Person | +| tst.ts:232:28:232:38 | other.#name | string | | type_alias.ts:3:5:3:5 | b | boolean | | type_alias.ts:7:5:7:5 | c | ValueOrArray | | type_alias.ts:14:9:14:32 | [proper ... ]: Json | any | @@ -340,6 +363,7 @@ getTypeDefinitionType | tst.ts:203:3:203:46 | type C ... mber>>; | C | | tst.ts:205:10:208:3 | interfa ... ng;\\n } | Success | | tst.ts:210:10:213:3 | interfa ... ng;\\n } | Error | +| tst.ts:222:3:234:3 | class P ... }\\n } | Person | | type_alias.ts:1:1:1:17 | type B = boolean; | boolean | | type_alias.ts:5:1:5:50 | type Va ... ay>; | ValueOrArray | | type_alias.ts:9:1:15:13 | type Js ... Json[]; | Json | @@ -539,6 +563,9 @@ getTypeExprType | tst.ts:215:30:215:36 | Success | Success | | tst.ts:215:30:215:44 | Success \| Error | Success \| Error | | tst.ts:215:40:215:44 | Error | Error | +| tst.ts:223:12:223:17 | string | string | +| tst.ts:224:23:224:28 | string | string | +| tst.ts:228:19:228:25 | unknown | unknown | | type_alias.ts:1:6:1:6 | B | boolean | | type_alias.ts:1:10:1:16 | boolean | boolean | | type_alias.ts:3:8:3:8 | B | boolean | @@ -625,6 +652,7 @@ referenceDefinition | MyUnion | tst.ts:65:1:65:54 | type My ... true}; | | MyUnion2 | tst.ts:68:1:68:49 | type My ... true}; | | NonAbstractDummy | tst.ts:54:1:56:1 | interfa ... mber;\\n} | +| Person | tst.ts:222:3:234:3 | class P ... }\\n } | | Shape | tst.ts:140:3:142:47 | type Sh ... mber }; | | Sub | tst.ts:97:3:101:3 | class S ... }\\n } | | Success | tst.ts:205:10:208:3 | interfa ... ng;\\n } | @@ -670,6 +698,9 @@ unknownType | tst.ts:48:14:48:14 | e | unknown | | tst.ts:133:16:133:18 | arg | unknown | | tst.ts:134:32:134:34 | arg | unknown | +| tst.ts:228:12:228:16 | other | unknown | +| tst.ts:229:16:229:20 | other | unknown | +| tst.ts:230:20:230:24 | other | unknown | abstractSignature | (): HasArea | | new (): HasArea | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts index 62bcb776a89..f460ad356c5 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts +++ b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts @@ -218,4 +218,18 @@ module TS45 { let token = r.body; } } + + class Person { + #name: string; + constructor(name: string) { + this.#name = name; + } + + equals(other: unknown) { + return other && + typeof other === "object" && + #name in other && // <- this is new! + this.#name === other.#name; // <- other has type Person here. + } + } } \ No newline at end of file From fdcc144a98c2e87752e6ae0492b3cd91595a42a5 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 23 Nov 2021 13:02:45 +0100 Subject: [PATCH 09/13] add test for import assertions --- .../TypeScript/Types/printAst.expected | 80 +++++++++++++------ .../TypeScript/Types/something.json | 3 + .../TypeScript/Types/tests.expected | 6 ++ .../TypeScript/Types/tsconfig.json | 3 +- .../library-tests/TypeScript/Types/tst.ts | 5 +- 5 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 javascript/ql/test/library-tests/TypeScript/Types/something.json diff --git a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected index 47b3d8601a2..4feb2eeb030 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected @@ -906,17 +906,29 @@ nodes | tst.ts:232:28:232:32 | [VarRef] other | semmle.label | [VarRef] other | | tst.ts:232:28:232:38 | [DotExpr] other.#name | semmle.label | [DotExpr] other.#name | | tst.ts:232:34:232:38 | [Label] #name | semmle.label | [Label] #name | +| tst.ts:237:1:237:65 | [ImportDeclaration] import ... son" }; | semmle.label | [ImportDeclaration] import ... son" }; | +| tst.ts:237:1:237:65 | [ImportDeclaration] import ... son" }; | semmle.order | 58 | +| tst.ts:237:8:237:16 | [ImportSpecifier] * as Foo3 | semmle.label | [ImportSpecifier] * as Foo3 | +| tst.ts:237:13:237:16 | [VarDecl] Foo3 | semmle.label | [VarDecl] Foo3 | +| tst.ts:237:23:237:40 | [Literal] "./something.json" | semmle.label | [Literal] "./something.json" | +| tst.ts:238:1:238:19 | [DeclStmt] var foo = ... | semmle.label | [DeclStmt] var foo = ... | +| tst.ts:238:1:238:19 | [DeclStmt] var foo = ... | semmle.order | 59 | +| tst.ts:238:5:238:7 | [VarDecl] foo | semmle.label | [VarDecl] foo | +| tst.ts:238:5:238:18 | [VariableDeclarator] foo = Foo3.foo | semmle.label | [VariableDeclarator] foo = Foo3.foo | +| tst.ts:238:11:238:14 | [VarRef] Foo3 | semmle.label | [VarRef] Foo3 | +| tst.ts:238:11:238:18 | [DotExpr] Foo3.foo | semmle.label | [DotExpr] Foo3.foo | +| tst.ts:238:16:238:18 | [Label] foo | semmle.label | [Label] foo | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | -| type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 58 | +| type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 60 | | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | [Identifier] B | | type_alias.ts:1:10:1:16 | [KeywordTypeExpr] boolean | semmle.label | [KeywordTypeExpr] boolean | | type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.label | [DeclStmt] var b = ... | -| type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.order | 59 | +| type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.order | 61 | | type_alias.ts:3:5:3:5 | [VarDecl] b | semmle.label | [VarDecl] b | | type_alias.ts:3:5:3:8 | [VariableDeclarator] b: B | semmle.label | [VariableDeclarator] b: B | | type_alias.ts:3:8:3:8 | [LocalTypeAccess] B | semmle.label | [LocalTypeAccess] B | | type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | -| type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.order | 60 | +| type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.order | 62 | | type_alias.ts:5:6:5:17 | [Identifier] ValueOrArray | semmle.label | [Identifier] ValueOrArray | | type_alias.ts:5:19:5:19 | [Identifier] T | semmle.label | [Identifier] T | | type_alias.ts:5:19:5:19 | [TypeParameter] T | semmle.label | [TypeParameter] T | @@ -928,14 +940,14 @@ nodes | type_alias.ts:5:34:5:48 | [GenericTypeExpr] ValueOrArray | semmle.label | [GenericTypeExpr] ValueOrArray | | type_alias.ts:5:47:5:47 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.label | [DeclStmt] var c = ... | -| type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.order | 61 | +| type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.order | 63 | | type_alias.ts:7:5:7:5 | [VarDecl] c | semmle.label | [VarDecl] c | | type_alias.ts:7:5:7:27 | [VariableDeclarator] c: Valu ... number> | semmle.label | [VariableDeclarator] c: Valu ... number> | | type_alias.ts:7:8:7:19 | [LocalTypeAccess] ValueOrArray | semmle.label | [LocalTypeAccess] ValueOrArray | | type_alias.ts:7:8:7:27 | [GenericTypeExpr] ValueOrArray | semmle.label | [GenericTypeExpr] ValueOrArray | | type_alias.ts:7:21:7:26 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | -| type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.order | 62 | +| type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.order | 64 | | type_alias.ts:9:6:9:9 | [Identifier] Json | semmle.label | [Identifier] Json | | type_alias.ts:10:5:15:12 | [UnionTypeExpr] \| strin ... Json[] | semmle.label | [UnionTypeExpr] \| strin ... Json[] | | type_alias.ts:10:7:10:12 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | @@ -951,12 +963,12 @@ nodes | type_alias.ts:15:7:15:10 | [LocalTypeAccess] Json | semmle.label | [LocalTypeAccess] Json | | type_alias.ts:15:7:15:12 | [ArrayTypeExpr] Json[] | semmle.label | [ArrayTypeExpr] Json[] | | type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.label | [DeclStmt] var json = ... | -| type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.order | 63 | +| type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.order | 65 | | type_alias.ts:17:5:17:8 | [VarDecl] json | semmle.label | [VarDecl] json | | type_alias.ts:17:5:17:14 | [VariableDeclarator] json: Json | semmle.label | [VariableDeclarator] json: Json | | type_alias.ts:17:11:17:14 | [LocalTypeAccess] Json | semmle.label | [LocalTypeAccess] Json | | type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | -| type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.order | 64 | +| type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.order | 66 | | type_alias.ts:19:6:19:16 | [Identifier] VirtualNode | semmle.label | [Identifier] VirtualNode | | type_alias.ts:20:5:21:56 | [UnionTypeExpr] \| strin ... Node[]] | semmle.label | [UnionTypeExpr] \| strin ... Node[]] | | type_alias.ts:20:7:20:12 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | @@ -972,7 +984,7 @@ nodes | type_alias.ts:21:43:21:53 | [LocalTypeAccess] VirtualNode | semmle.label | [LocalTypeAccess] VirtualNode | | type_alias.ts:21:43:21:55 | [ArrayTypeExpr] VirtualNode[] | semmle.label | [ArrayTypeExpr] VirtualNode[] | | type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.label | [DeclStmt] const myNode = ... | -| type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.order | 65 | +| type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.order | 67 | | type_alias.ts:23:7:23:12 | [VarDecl] myNode | semmle.label | [VarDecl] myNode | | type_alias.ts:23:7:27:5 | [VariableDeclarator] myNode: ... ] ] | semmle.label | [VariableDeclarator] myNode: ... ] ] | | type_alias.ts:23:15:23:25 | [LocalTypeAccess] VirtualNode | semmle.label | [LocalTypeAccess] VirtualNode | @@ -997,12 +1009,12 @@ nodes | type_alias.ts:26:23:26:36 | [Literal] "second-child" | semmle.label | [Literal] "second-child" | | type_alias.ts:26:41:26:62 | [Literal] "I'm the second child" | semmle.label | [Literal] "I'm the second child" | | type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.label | [ImportDeclaration] import ... dummy"; | -| type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 66 | +| type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 68 | | type_definition_objects.ts:1:8:1:17 | [ImportSpecifier] * as dummy | semmle.label | [ImportSpecifier] * as dummy | | type_definition_objects.ts:1:13:1:17 | [VarDecl] dummy | semmle.label | [VarDecl] dummy | | type_definition_objects.ts:1:24:1:32 | [Literal] "./dummy" | semmle.label | [Literal] "./dummy" | | type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.label | [ExportDeclaration] export class C {} | -| type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.order | 67 | +| type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.order | 69 | | type_definition_objects.ts:3:8:3:17 | [ClassDefinition,TypeDefinition] class C {} | semmle.label | [ClassDefinition,TypeDefinition] class C {} | | type_definition_objects.ts:3:14:3:14 | [VarDecl] C | semmle.label | [VarDecl] C | | type_definition_objects.ts:3:16:3:15 | [BlockStmt] {} | semmle.label | [BlockStmt] {} | @@ -1010,36 +1022,36 @@ nodes | type_definition_objects.ts:3:16:3:15 | [FunctionExpr] () {} | semmle.label | [FunctionExpr] () {} | | type_definition_objects.ts:3:16:3:15 | [Label] constructor | semmle.label | [Label] constructor | | type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.label | [DeclStmt] let classObj = ... | -| type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.order | 68 | +| type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.order | 70 | | type_definition_objects.ts:4:5:4:12 | [VarDecl] classObj | semmle.label | [VarDecl] classObj | | type_definition_objects.ts:4:5:4:16 | [VariableDeclarator] classObj = C | semmle.label | [VariableDeclarator] classObj = C | | type_definition_objects.ts:4:16:4:16 | [VarRef] C | semmle.label | [VarRef] C | | type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.label | [ExportDeclaration] export enum E {} | -| type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.order | 69 | +| type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.order | 71 | | type_definition_objects.ts:6:8:6:16 | [EnumDeclaration,TypeDefinition] enum E {} | semmle.label | [EnumDeclaration,TypeDefinition] enum E {} | | type_definition_objects.ts:6:13:6:13 | [VarDecl] E | semmle.label | [VarDecl] E | | type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.label | [DeclStmt] let enumObj = ... | -| type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.order | 70 | +| type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.order | 72 | | type_definition_objects.ts:7:5:7:11 | [VarDecl] enumObj | semmle.label | [VarDecl] enumObj | | type_definition_objects.ts:7:5:7:15 | [VariableDeclarator] enumObj = E | semmle.label | [VariableDeclarator] enumObj = E | | type_definition_objects.ts:7:15:7:15 | [VarRef] E | semmle.label | [VarRef] E | | type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.label | [ExportDeclaration] export ... e N {;} | -| type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.order | 71 | +| type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.order | 73 | | type_definition_objects.ts:9:8:9:22 | [NamespaceDeclaration] namespace N {;} | semmle.label | [NamespaceDeclaration] namespace N {;} | | type_definition_objects.ts:9:18:9:18 | [VarDecl] N | semmle.label | [VarDecl] N | | type_definition_objects.ts:9:21:9:21 | [EmptyStmt] ; | semmle.label | [EmptyStmt] ; | | type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.label | [DeclStmt] let namespaceObj = ... | -| type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.order | 72 | +| type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.order | 74 | | type_definition_objects.ts:10:5:10:16 | [VarDecl] namespaceObj | semmle.label | [VarDecl] namespaceObj | | type_definition_objects.ts:10:5:10:20 | [VariableDeclarator] namespaceObj = N | semmle.label | [VariableDeclarator] namespaceObj = N | | type_definition_objects.ts:10:20:10:20 | [VarRef] N | semmle.label | [VarRef] N | | type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.label | [ImportDeclaration] import ... dummy"; | -| type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 73 | +| type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 75 | | type_definitions.ts:1:8:1:17 | [ImportSpecifier] * as dummy | semmle.label | [ImportSpecifier] * as dummy | | type_definitions.ts:1:13:1:17 | [VarDecl] dummy | semmle.label | [VarDecl] dummy | | type_definitions.ts:1:24:1:32 | [Literal] "./dummy" | semmle.label | [Literal] "./dummy" | | type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.label | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | -| type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.order | 74 | +| type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.order | 76 | | type_definitions.ts:3:11:3:11 | [Identifier] I | semmle.label | [Identifier] I | | type_definitions.ts:3:13:3:13 | [Identifier] S | semmle.label | [Identifier] S | | type_definitions.ts:3:13:3:13 | [TypeParameter] S | semmle.label | [TypeParameter] S | @@ -1047,14 +1059,14 @@ nodes | type_definitions.ts:4:3:4:7 | [FieldDeclaration] x: S; | semmle.label | [FieldDeclaration] x: S; | | type_definitions.ts:4:6:4:6 | [LocalTypeAccess] S | semmle.label | [LocalTypeAccess] S | | type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.label | [DeclStmt] let i = ... | -| type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.order | 75 | +| type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.order | 77 | | type_definitions.ts:6:5:6:5 | [VarDecl] i | semmle.label | [VarDecl] i | | type_definitions.ts:6:5:6:16 | [VariableDeclarator] i: I | semmle.label | [VariableDeclarator] i: I | | type_definitions.ts:6:8:6:8 | [LocalTypeAccess] I | semmle.label | [LocalTypeAccess] I | | type_definitions.ts:6:8:6:16 | [GenericTypeExpr] I | semmle.label | [GenericTypeExpr] I | | type_definitions.ts:6:10:6:15 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.label | [ClassDefinition,TypeDefinition] class C ... x: T } | -| type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.order | 76 | +| type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.order | 78 | | type_definitions.ts:8:7:8:7 | [VarDecl] C | semmle.label | [VarDecl] C | | type_definitions.ts:8:8:8:7 | [BlockStmt] {} | semmle.label | [BlockStmt] {} | | type_definitions.ts:8:8:8:7 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | semmle.label | [ClassInitializedMember,ConstructorDefinition] constructor() {} | @@ -1066,14 +1078,14 @@ nodes | type_definitions.ts:9:3:9:6 | [FieldDeclaration] x: T | semmle.label | [FieldDeclaration] x: T | | type_definitions.ts:9:6:9:6 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.label | [DeclStmt] let c = ... | -| type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.order | 77 | +| type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.order | 79 | | type_definitions.ts:11:5:11:5 | [VarDecl] c | semmle.label | [VarDecl] c | | type_definitions.ts:11:5:11:16 | [VariableDeclarator] c: C | semmle.label | [VariableDeclarator] c: C | | type_definitions.ts:11:8:11:8 | [LocalTypeAccess] C | semmle.label | [LocalTypeAccess] C | | type_definitions.ts:11:8:11:16 | [GenericTypeExpr] C | semmle.label | [GenericTypeExpr] C | | type_definitions.ts:11:10:11:15 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.label | [EnumDeclaration,TypeDefinition] enum Co ... blue } | -| type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.order | 78 | +| type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.order | 80 | | type_definitions.ts:13:6:13:10 | [VarDecl] Color | semmle.label | [VarDecl] Color | | type_definitions.ts:14:3:14:5 | [EnumMember,TypeDefinition] red | semmle.label | [EnumMember,TypeDefinition] red | | type_definitions.ts:14:3:14:5 | [VarDecl] red | semmle.label | [VarDecl] red | @@ -1082,29 +1094,29 @@ nodes | type_definitions.ts:14:15:14:18 | [EnumMember,TypeDefinition] blue | semmle.label | [EnumMember,TypeDefinition] blue | | type_definitions.ts:14:15:14:18 | [VarDecl] blue | semmle.label | [VarDecl] blue | | type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.label | [DeclStmt] let color = ... | -| type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.order | 79 | +| type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.order | 81 | | type_definitions.ts:16:5:16:9 | [VarDecl] color | semmle.label | [VarDecl] color | | type_definitions.ts:16:5:16:16 | [VariableDeclarator] color: Color | semmle.label | [VariableDeclarator] color: Color | | type_definitions.ts:16:12:16:16 | [LocalTypeAccess] Color | semmle.label | [LocalTypeAccess] Color | | type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.label | [EnumDeclaration,TypeDefinition] enum En ... ember } | -| type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.order | 80 | +| type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.order | 82 | | type_definitions.ts:18:6:18:22 | [VarDecl] EnumWithOneMember | semmle.label | [VarDecl] EnumWithOneMember | | type_definitions.ts:18:26:18:31 | [EnumMember,TypeDefinition] member | semmle.label | [EnumMember,TypeDefinition] member | | type_definitions.ts:18:26:18:31 | [VarDecl] member | semmle.label | [VarDecl] member | | type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.label | [DeclStmt] let e = ... | -| type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.order | 81 | +| type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.order | 83 | | type_definitions.ts:19:5:19:5 | [VarDecl] e | semmle.label | [VarDecl] e | | type_definitions.ts:19:5:19:24 | [VariableDeclarator] e: EnumWithOneMember | semmle.label | [VariableDeclarator] e: EnumWithOneMember | | type_definitions.ts:19:8:19:24 | [LocalTypeAccess] EnumWithOneMember | semmle.label | [LocalTypeAccess] EnumWithOneMember | | type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | -| type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.order | 82 | +| type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.order | 84 | | type_definitions.ts:21:6:21:10 | [Identifier] Alias | semmle.label | [Identifier] Alias | | type_definitions.ts:21:12:21:12 | [Identifier] T | semmle.label | [Identifier] T | | type_definitions.ts:21:12:21:12 | [TypeParameter] T | semmle.label | [TypeParameter] T | | type_definitions.ts:21:17:21:17 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_definitions.ts:21:17:21:19 | [ArrayTypeExpr] T[] | semmle.label | [ArrayTypeExpr] T[] | | type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.label | [DeclStmt] let aliasForNumberArray = ... | -| type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.order | 83 | +| type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.order | 85 | | type_definitions.ts:22:5:22:23 | [VarDecl] aliasForNumberArray | semmle.label | [VarDecl] aliasForNumberArray | | type_definitions.ts:22:5:22:38 | [VariableDeclarator] aliasFo ... number> | semmle.label | [VariableDeclarator] aliasFo ... number> | | type_definitions.ts:22:26:22:30 | [LocalTypeAccess] Alias | semmle.label | [LocalTypeAccess] Alias | @@ -2697,6 +2709,22 @@ edges | tst.ts:232:28:232:38 | [DotExpr] other.#name | tst.ts:232:28:232:32 | [VarRef] other | semmle.order | 1 | | tst.ts:232:28:232:38 | [DotExpr] other.#name | tst.ts:232:34:232:38 | [Label] #name | semmle.label | 2 | | tst.ts:232:28:232:38 | [DotExpr] other.#name | tst.ts:232:34:232:38 | [Label] #name | semmle.order | 2 | +| tst.ts:237:1:237:65 | [ImportDeclaration] import ... son" }; | tst.ts:237:8:237:16 | [ImportSpecifier] * as Foo3 | semmle.label | 1 | +| tst.ts:237:1:237:65 | [ImportDeclaration] import ... son" }; | tst.ts:237:8:237:16 | [ImportSpecifier] * as Foo3 | semmle.order | 1 | +| tst.ts:237:1:237:65 | [ImportDeclaration] import ... son" }; | tst.ts:237:23:237:40 | [Literal] "./something.json" | semmle.label | 2 | +| tst.ts:237:1:237:65 | [ImportDeclaration] import ... son" }; | tst.ts:237:23:237:40 | [Literal] "./something.json" | semmle.order | 2 | +| tst.ts:237:8:237:16 | [ImportSpecifier] * as Foo3 | tst.ts:237:13:237:16 | [VarDecl] Foo3 | semmle.label | 1 | +| tst.ts:237:8:237:16 | [ImportSpecifier] * as Foo3 | tst.ts:237:13:237:16 | [VarDecl] Foo3 | semmle.order | 1 | +| tst.ts:238:1:238:19 | [DeclStmt] var foo = ... | tst.ts:238:5:238:18 | [VariableDeclarator] foo = Foo3.foo | semmle.label | 1 | +| tst.ts:238:1:238:19 | [DeclStmt] var foo = ... | tst.ts:238:5:238:18 | [VariableDeclarator] foo = Foo3.foo | semmle.order | 1 | +| tst.ts:238:5:238:18 | [VariableDeclarator] foo = Foo3.foo | tst.ts:238:5:238:7 | [VarDecl] foo | semmle.label | 1 | +| tst.ts:238:5:238:18 | [VariableDeclarator] foo = Foo3.foo | tst.ts:238:5:238:7 | [VarDecl] foo | semmle.order | 1 | +| tst.ts:238:5:238:18 | [VariableDeclarator] foo = Foo3.foo | tst.ts:238:11:238:18 | [DotExpr] Foo3.foo | semmle.label | 2 | +| tst.ts:238:5:238:18 | [VariableDeclarator] foo = Foo3.foo | tst.ts:238:11:238:18 | [DotExpr] Foo3.foo | semmle.order | 2 | +| tst.ts:238:11:238:18 | [DotExpr] Foo3.foo | tst.ts:238:11:238:14 | [VarRef] Foo3 | semmle.label | 1 | +| tst.ts:238:11:238:18 | [DotExpr] Foo3.foo | tst.ts:238:11:238:14 | [VarRef] Foo3 | semmle.order | 1 | +| tst.ts:238:11:238:18 | [DotExpr] Foo3.foo | tst.ts:238:16:238:18 | [Label] foo | semmle.label | 2 | +| tst.ts:238:11:238:18 | [DotExpr] Foo3.foo | tst.ts:238:16:238:18 | [Label] foo | semmle.order | 2 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.order | 1 | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | type_alias.ts:1:10:1:16 | [KeywordTypeExpr] boolean | semmle.label | 2 | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/something.json b/javascript/ql/test/library-tests/TypeScript/Types/something.json new file mode 100644 index 00000000000..8a79687628f --- /dev/null +++ b/javascript/ql/test/library-tests/TypeScript/Types/something.json @@ -0,0 +1,3 @@ +{ + "foo": "bar" +} \ No newline at end of file diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected index 1bc82e8a02b..dc32d04304f 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected @@ -295,6 +295,12 @@ getExprType | tst.ts:232:13:232:38 | this.#n ... r.#name | boolean | | tst.ts:232:28:232:32 | other | Person | | tst.ts:232:28:232:38 | other.#name | string | +| tst.ts:237:13:237:16 | Foo3 | { foo: string; } | +| tst.ts:237:23:237:40 | "./something.json" | any | +| tst.ts:238:5:238:7 | foo | string | +| tst.ts:238:11:238:14 | Foo3 | { foo: string; } | +| tst.ts:238:11:238:18 | Foo3.foo | string | +| tst.ts:238:16:238:18 | foo | string | | type_alias.ts:3:5:3:5 | b | boolean | | type_alias.ts:7:5:7:5 | c | ValueOrArray | | type_alias.ts:14:9:14:32 | [proper ... ]: Json | any | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/Types/tsconfig.json index 8f3c6567968..4732b4ed706 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tsconfig.json +++ b/javascript/ql/test/library-tests/TypeScript/Types/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { - "lib": ["es2015"] + "lib": ["es2015"], + "resolveJsonModule": true } } diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts index f460ad356c5..fe8072eef15 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts +++ b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts @@ -232,4 +232,7 @@ module TS45 { this.#name === other.#name; // <- other has type Person here. } } -} \ No newline at end of file +} + +import * as Foo3 from "./something.json" assert { type: "json" }; +var foo = Foo3.foo; \ No newline at end of file From de53727ab3378f9540223d0c2615cefd5403f52e Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Wed, 1 Dec 2021 14:29:57 +0100 Subject: [PATCH 10/13] remove spurious whitespace Co-authored-by: Asger F --- .../LanguageFeatures/SyntaxError/destructingPrivate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js index 1ca86fe4aa0..060111d86b4 100644 --- a/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js +++ b/javascript/ql/test/query-tests/LanguageFeatures/SyntaxError/destructingPrivate.js @@ -1,6 +1,6 @@ class C { #privDecl; bar() { - {#privDecl} = this; + {#privDecl} = this; } } \ No newline at end of file From 739906b60cb6c9a746b04a76f0702f74adaedab3 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Wed, 1 Dec 2021 14:47:11 +0100 Subject: [PATCH 11/13] rename @import_or_export_declaration to @type_keyword_operand --- javascript/ql/lib/semmlecode.javascript.dbscheme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javascript/ql/lib/semmlecode.javascript.dbscheme b/javascript/ql/lib/semmlecode.javascript.dbscheme index 839d9abe84c..c1ee5346e06 100644 --- a/javascript/ql/lib/semmlecode.javascript.dbscheme +++ b/javascript/ql/lib/semmlecode.javascript.dbscheme @@ -392,7 +392,7 @@ case @expr.kind of @exportspecifier = @named_export_specifier | @export_default_specifier | @export_namespace_specifier; -@import_or_export_declaration = @import_declaration | @export_declaration | @import_specifier; +@type_keyword_operand = @import_declaration | @export_declaration | @import_specifier; @type_assertion = @as_type_assertion | @prefix_type_assertion; @@ -541,7 +541,7 @@ has_public_keyword (int id: @property ref); has_private_keyword (int id: @property ref); has_protected_keyword (int id: @property ref); has_readonly_keyword (int id: @property ref); -has_type_keyword (int id: @import_or_export_declaration ref); +has_type_keyword (int id: @type_keyword_operand ref); is_optional_member (int id: @property ref); has_definite_assignment_assertion (int id: @field_or_vardeclarator ref); is_optional_parameter_declaration (unique int parameter: @pattern ref); From 73f2f52ed83627e6f98b00f35221f65a4ff10680 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Wed, 1 Dec 2021 14:54:16 +0100 Subject: [PATCH 12/13] use the `TYPE_ONLY_IMPORT` context --- .../extractor/src/com/semmle/js/extractor/ASTExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java index dee68f7f3a0..e1c059a9088 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java @@ -1812,7 +1812,7 @@ public class ASTExtractor { public Label visit(ImportSpecifier nd, Context c) { Label lbl = super.visit(nd, c); visit(nd.getImported(), lbl, 0, IdContext.LABEL); - visit(nd.getLocal(), lbl, 1, c.idcontext); + visit(nd.getLocal(), lbl, 1, nd.hasTypeKeyword() ? IdContext.TYPE_ONLY_IMPORT : c.idcontext); if (nd.hasTypeKeyword()) { trapwriter.addTuple("has_type_keyword", lbl); } From 3145e8f9b7ddb496b65276f4eeb9c2a773449e5a Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Wed, 8 Dec 2021 10:53:47 +0100 Subject: [PATCH 13/13] add upgrade script --- .../old.dbscheme | 1217 +++++++++++++++++ .../semmlecode.javascript.dbscheme | 1217 +++++++++++++++++ .../upgrade.properties | 2 + 3 files changed, 2436 insertions(+) create mode 100644 javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/old.dbscheme create mode 100644 javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/semmlecode.javascript.dbscheme create mode 100644 javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/upgrade.properties diff --git a/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/old.dbscheme b/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/old.dbscheme new file mode 100644 index 00000000000..8320e9d13aa --- /dev/null +++ b/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/old.dbscheme @@ -0,0 +1,1217 @@ +/*** Standard fragments ***/ + +/** Files and folders **/ + +@location = @location_default; + +locations_default(unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref + ); + +@sourceline = @locatable; + +numlines(int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref + ); + +files(unique int id: @file, + varchar(900) name: string ref); + +folders(unique int id: @folder, + varchar(900) name: string ref); + + +@container = @folder | @file ; + + +containerparent(int parent: @container ref, + unique int child: @container ref); + +/** Duplicate code **/ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity; + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/** External data **/ + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +/** Version control data **/ + +svnentries( + int id : @svnentry, + varchar(500) revision : string ref, + varchar(500) author : string ref, + date revisionDate : date ref, + int changeSize : int ref +); + +svnaffectedfiles( + int id : @svnentry ref, + int file : @file ref, + varchar(500) action : string ref +); + +svnentrymsg( + int id : @svnentry ref, + varchar(500) message : string ref +); + +svnchurn( + int commit : @svnentry ref, + int file : @file ref, + int addedLines : int ref, + int deletedLines : int ref +); + + +/*** JavaScript-specific part ***/ + +filetype( + int file: @file ref, + string filetype: string ref +) + +// top-level code fragments +toplevels (unique int id: @toplevel, + int kind: int ref); + +is_externs (int toplevel: @toplevel ref); + +case @toplevel.kind of + 0 = @script +| 1 = @inline_script +| 2 = @event_handler +| 3 = @javascript_url +| 4 = @template_toplevel; + +is_module (int tl: @toplevel ref); +is_nodejs (int tl: @toplevel ref); +is_es2015_module (int tl: @toplevel ref); +is_closure_module (int tl: @toplevel ref); + +@xml_node_with_code = @xmlelement | @xmlattribute | @template_placeholder_tag; +toplevel_parent_xml_node( + unique int toplevel: @toplevel ref, + int xmlnode: @xml_node_with_code ref); + +xml_element_parent_expression( + unique int xmlnode: @xmlelement ref, + int expression: @expr ref, + int index: int ref); + +// statements +#keyset[parent, idx] +stmts (unique int id: @stmt, + int kind: int ref, + int parent: @stmt_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +stmt_containers (unique int stmt: @stmt ref, + int container: @stmt_container ref); + +jump_targets (unique int jump: @stmt ref, + int target: @stmt ref); + +@stmt_parent = @stmt | @toplevel | @function_expr | @arrow_function_expr | @static_initializer; +@stmt_container = @toplevel | @function | @namespace_declaration | @external_module_declaration | @global_augmentation_declaration; + +case @stmt.kind of + 0 = @empty_stmt +| 1 = @block_stmt +| 2 = @expr_stmt +| 3 = @if_stmt +| 4 = @labeled_stmt +| 5 = @break_stmt +| 6 = @continue_stmt +| 7 = @with_stmt +| 8 = @switch_stmt +| 9 = @return_stmt +| 10 = @throw_stmt +| 11 = @try_stmt +| 12 = @while_stmt +| 13 = @do_while_stmt +| 14 = @for_stmt +| 15 = @for_in_stmt +| 16 = @debugger_stmt +| 17 = @function_decl_stmt +| 18 = @var_decl_stmt +| 19 = @case +| 20 = @catch_clause +| 21 = @for_of_stmt +| 22 = @const_decl_stmt +| 23 = @let_stmt +| 24 = @legacy_let_stmt +| 25 = @for_each_stmt +| 26 = @class_decl_stmt +| 27 = @import_declaration +| 28 = @export_all_declaration +| 29 = @export_default_declaration +| 30 = @export_named_declaration +| 31 = @namespace_declaration +| 32 = @import_equals_declaration +| 33 = @export_assign_declaration +| 34 = @interface_declaration +| 35 = @type_alias_declaration +| 36 = @enum_declaration +| 37 = @external_module_declaration +| 38 = @export_as_namespace_declaration +| 39 = @global_augmentation_declaration +; + +@decl_stmt = @var_decl_stmt | @const_decl_stmt | @let_stmt | @legacy_let_stmt; + +@export_declaration = @export_all_declaration | @export_default_declaration | @export_named_declaration; + +@namespace_definition = @namespace_declaration | @enum_declaration; +@type_definition = @class_definition | @interface_declaration | @enum_declaration | @type_alias_declaration | @enum_member; + +is_instantiated(unique int decl: @namespace_declaration ref); + +@declarable_node = @decl_stmt | @namespace_declaration | @class_decl_stmt | @function_decl_stmt | @enum_declaration | @external_module_declaration | @global_augmentation_declaration | @field; +has_declare_keyword(unique int stmt: @declarable_node ref); + +is_for_await_of(unique int forof: @for_of_stmt ref); + +// expressions +#keyset[parent, idx] +exprs (unique int id: @expr, + int kind: int ref, + int parent: @expr_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +literals (varchar(900) value: string ref, + varchar(900) raw: string ref, + unique int expr: @expr_or_type ref); + +enclosing_stmt (unique int expr: @expr_or_type ref, + int stmt: @stmt ref); + +expr_containers (unique int expr: @expr_or_type ref, + int container: @stmt_container ref); + +array_size (unique int ae: @arraylike ref, + int sz: int ref); + +is_delegating (int yield: @yield_expr ref); + +@expr_or_stmt = @expr | @stmt; +@expr_or_type = @expr | @typeexpr; +@expr_parent = @expr_or_stmt | @property | @function_typeexpr; +@arraylike = @array_expr | @array_pattern; +@type_annotation = @typeexpr | @jsdoc_type_expr; +@node_in_stmt_container = @cfg_node | @type_annotation | @toplevel; + +case @expr.kind of + 0 = @label +| 1 = @null_literal +| 2 = @boolean_literal +| 3 = @number_literal +| 4 = @string_literal +| 5 = @regexp_literal +| 6 = @this_expr +| 7 = @array_expr +| 8 = @obj_expr +| 9 = @function_expr +| 10 = @seq_expr +| 11 = @conditional_expr +| 12 = @new_expr +| 13 = @call_expr +| 14 = @dot_expr +| 15 = @index_expr +| 16 = @neg_expr +| 17 = @plus_expr +| 18 = @log_not_expr +| 19 = @bit_not_expr +| 20 = @typeof_expr +| 21 = @void_expr +| 22 = @delete_expr +| 23 = @eq_expr +| 24 = @neq_expr +| 25 = @eqq_expr +| 26 = @neqq_expr +| 27 = @lt_expr +| 28 = @le_expr +| 29 = @gt_expr +| 30 = @ge_expr +| 31 = @lshift_expr +| 32 = @rshift_expr +| 33 = @urshift_expr +| 34 = @add_expr +| 35 = @sub_expr +| 36 = @mul_expr +| 37 = @div_expr +| 38 = @mod_expr +| 39 = @bitor_expr +| 40 = @xor_expr +| 41 = @bitand_expr +| 42 = @in_expr +| 43 = @instanceof_expr +| 44 = @logand_expr +| 45 = @logor_expr +| 47 = @assign_expr +| 48 = @assign_add_expr +| 49 = @assign_sub_expr +| 50 = @assign_mul_expr +| 51 = @assign_div_expr +| 52 = @assign_mod_expr +| 53 = @assign_lshift_expr +| 54 = @assign_rshift_expr +| 55 = @assign_urshift_expr +| 56 = @assign_or_expr +| 57 = @assign_xor_expr +| 58 = @assign_and_expr +| 59 = @preinc_expr +| 60 = @postinc_expr +| 61 = @predec_expr +| 62 = @postdec_expr +| 63 = @par_expr +| 64 = @var_declarator +| 65 = @arrow_function_expr +| 66 = @spread_element +| 67 = @array_pattern +| 68 = @object_pattern +| 69 = @yield_expr +| 70 = @tagged_template_expr +| 71 = @template_literal +| 72 = @template_element +| 73 = @array_comprehension_expr +| 74 = @generator_expr +| 75 = @for_in_comprehension_block +| 76 = @for_of_comprehension_block +| 77 = @legacy_letexpr +| 78 = @var_decl +| 79 = @proper_varaccess +| 80 = @class_expr +| 81 = @super_expr +| 82 = @newtarget_expr +| 83 = @named_import_specifier +| 84 = @import_default_specifier +| 85 = @import_namespace_specifier +| 86 = @named_export_specifier +| 87 = @exp_expr +| 88 = @assign_exp_expr +| 89 = @jsx_element +| 90 = @jsx_qualified_name +| 91 = @jsx_empty_expr +| 92 = @await_expr +| 93 = @function_sent_expr +| 94 = @decorator +| 95 = @export_default_specifier +| 96 = @export_namespace_specifier +| 97 = @bind_expr +| 98 = @external_module_reference +| 99 = @dynamic_import +| 100 = @expression_with_type_arguments +| 101 = @prefix_type_assertion +| 102 = @as_type_assertion +| 103 = @export_varaccess +| 104 = @decorator_list +| 105 = @non_null_assertion +| 106 = @bigint_literal +| 107 = @nullishcoalescing_expr +| 108 = @e4x_xml_anyname +| 109 = @e4x_xml_static_attribute_selector +| 110 = @e4x_xml_dynamic_attribute_selector +| 111 = @e4x_xml_filter_expression +| 112 = @e4x_xml_static_qualident +| 113 = @e4x_xml_dynamic_qualident +| 114 = @e4x_xml_dotdotexpr +| 115 = @import_meta_expr +| 116 = @assignlogandexpr +| 117 = @assignlogorexpr +| 118 = @assignnullishcoalescingexpr +| 119 = @template_pipe_ref +| 120 = @generated_code_expr +; + +@varaccess = @proper_varaccess | @export_varaccess; +@varref = @var_decl | @varaccess; + +@identifier = @label | @varref | @type_identifier; + +@literal = @null_literal | @boolean_literal | @number_literal | @string_literal | @regexp_literal | @bigint_literal; + +@propaccess = @dot_expr | @index_expr; + +@invokeexpr = @new_expr | @call_expr; + +@unaryexpr = @neg_expr | @plus_expr | @log_not_expr | @bit_not_expr | @typeof_expr | @void_expr | @delete_expr | @spread_element; + +@equality_test = @eq_expr | @neq_expr | @eqq_expr | @neqq_expr; + +@comparison = @equality_test | @lt_expr | @le_expr | @gt_expr | @ge_expr; + +@binaryexpr = @comparison | @lshift_expr | @rshift_expr | @urshift_expr | @add_expr | @sub_expr | @mul_expr | @div_expr | @mod_expr | @exp_expr | @bitor_expr | @xor_expr | @bitand_expr | @in_expr | @instanceof_expr | @logand_expr | @logor_expr | @nullishcoalescing_expr; + +@assignment = @assign_expr | @assign_add_expr | @assign_sub_expr | @assign_mul_expr | @assign_div_expr | @assign_mod_expr | @assign_exp_expr | @assign_lshift_expr | @assign_rshift_expr | @assign_urshift_expr | @assign_or_expr | @assign_xor_expr | @assign_and_expr | @assignlogandexpr | @assignlogorexpr | @assignnullishcoalescingexpr; + +@updateexpr = @preinc_expr | @postinc_expr | @predec_expr | @postdec_expr; + +@pattern = @varref | @array_pattern | @object_pattern; + +@comprehension_expr = @array_comprehension_expr | @generator_expr; + +@comprehension_block = @for_in_comprehension_block | @for_of_comprehension_block; + +@import_specifier = @named_import_specifier | @import_default_specifier | @import_namespace_specifier; + +@exportspecifier = @named_export_specifier | @export_default_specifier | @export_namespace_specifier; + +@import_or_export_declaration = @import_declaration | @export_declaration; + +@type_assertion = @as_type_assertion | @prefix_type_assertion; + +@class_definition = @class_decl_stmt | @class_expr; +@interface_definition = @interface_declaration | @interface_typeexpr; +@class_or_interface = @class_definition | @interface_definition; + +@lexical_decl = @var_decl | @type_decl; +@lexical_access = @varaccess | @local_type_access | @local_var_type_access | @local_namespace_access; +@lexical_ref = @lexical_decl | @lexical_access; + +@e4x_xml_attribute_selector = @e4x_xml_static_attribute_selector | @e4x_xml_dynamic_attribute_selector; +@e4x_xml_qualident = @e4x_xml_static_qualident | @e4x_xml_dynamic_qualident; + +expr_contains_template_tag_location( + int expr: @expr ref, + int location: @location ref +); + +@template_placeholder_tag_parent = @xmlelement | @xmlattribute | @file; + +template_placeholder_tag_info( + unique int node: @template_placeholder_tag, + int parentNode: @template_placeholder_tag_parent ref, + varchar(900) raw: string ref +); + +// scopes +scopes (unique int id: @scope, + int kind: int ref); + +case @scope.kind of + 0 = @global_scope +| 1 = @function_scope +| 2 = @catch_scope +| 3 = @module_scope +| 4 = @block_scope +| 5 = @for_scope +| 6 = @for_in_scope // for-of scopes work the same as for-in scopes +| 7 = @comprehension_block_scope +| 8 = @class_expr_scope +| 9 = @namespace_scope +| 10 = @class_decl_scope +| 11 = @interface_scope +| 12 = @type_alias_scope +| 13 = @mapped_type_scope +| 14 = @enum_scope +| 15 = @external_module_scope +| 16 = @conditional_type_scope; + +scopenodes (unique int node: @ast_node ref, + int scope: @scope ref); + +scopenesting (unique int inner: @scope ref, + int outer: @scope ref); + +// functions +@function = @function_decl_stmt | @function_expr | @arrow_function_expr; + +@parameterized = @function | @catch_clause; +@type_parameterized = @function | @class_or_interface | @type_alias_declaration | @mapped_typeexpr | @infer_typeexpr; + +is_generator (int fun: @function ref); +has_rest_parameter (int fun: @function ref); +is_async (int fun: @function ref); + +// variables and lexically scoped type names +#keyset[scope, name] +variables (unique int id: @variable, + varchar(900) name: string ref, + int scope: @scope ref); + +#keyset[scope, name] +local_type_names (unique int id: @local_type_name, + varchar(900) name: string ref, + int scope: @scope ref); + +#keyset[scope, name] +local_namespace_names (unique int id: @local_namespace_name, + varchar(900) name: string ref, + int scope: @scope ref); + +is_arguments_object (int id: @variable ref); + +@lexical_name = @variable | @local_type_name | @local_namespace_name; + +@bind_id = @varaccess | @local_var_type_access; +bind (unique int id: @bind_id ref, + int decl: @variable ref); + +decl (unique int id: @var_decl ref, + int decl: @variable ref); + +@typebind_id = @local_type_access | @export_varaccess; +typebind (unique int id: @typebind_id ref, + int decl: @local_type_name ref); + +@typedecl_id = @type_decl | @var_decl; +typedecl (unique int id: @typedecl_id ref, + int decl: @local_type_name ref); + +namespacedecl (unique int id: @var_decl ref, + int decl: @local_namespace_name ref); + +@namespacebind_id = @local_namespace_access | @export_varaccess; +namespacebind (unique int id: @namespacebind_id ref, + int decl: @local_namespace_name ref); + + +// properties in object literals, property patterns in object patterns, and method declarations in classes +#keyset[parent, index] +properties (unique int id: @property, + int parent: @property_parent ref, + int index: int ref, + int kind: int ref, + varchar(900) tostring: string ref); + +case @property.kind of + 0 = @value_property +| 1 = @property_getter +| 2 = @property_setter +| 3 = @jsx_attribute +| 4 = @function_call_signature +| 5 = @constructor_call_signature +| 6 = @index_signature +| 7 = @enum_member +| 8 = @proper_field +| 9 = @parameter_field +| 10 = @static_initializer +; + +@property_parent = @obj_expr | @object_pattern | @class_definition | @jsx_element | @interface_definition | @enum_declaration; +@property_accessor = @property_getter | @property_setter; +@call_signature = @function_call_signature | @constructor_call_signature; +@field = @proper_field | @parameter_field; +@field_or_vardeclarator = @field | @var_declarator; + +is_computed (int id: @property ref); +is_method (int id: @property ref); +is_static (int id: @property ref); +is_abstract_member (int id: @property ref); +is_const_enum (int id: @enum_declaration ref); +is_abstract_class (int id: @class_decl_stmt ref); + +has_public_keyword (int id: @property ref); +has_private_keyword (int id: @property ref); +has_protected_keyword (int id: @property ref); +has_readonly_keyword (int id: @property ref); +has_type_keyword (int id: @import_or_export_declaration ref); +is_optional_member (int id: @property ref); +has_definite_assignment_assertion (int id: @field_or_vardeclarator ref); +is_optional_parameter_declaration (unique int parameter: @pattern ref); + +#keyset[constructor, param_index] +parameter_fields( + unique int field: @parameter_field ref, + int constructor: @function_expr ref, + int param_index: int ref +); + +// types +#keyset[parent, idx] +typeexprs ( + unique int id: @typeexpr, + int kind: int ref, + int parent: @typeexpr_parent ref, + int idx: int ref, + varchar(900) tostring: string ref +); + +case @typeexpr.kind of + 0 = @local_type_access +| 1 = @type_decl +| 2 = @keyword_typeexpr +| 3 = @string_literal_typeexpr +| 4 = @number_literal_typeexpr +| 5 = @boolean_literal_typeexpr +| 6 = @array_typeexpr +| 7 = @union_typeexpr +| 8 = @indexed_access_typeexpr +| 9 = @intersection_typeexpr +| 10 = @parenthesized_typeexpr +| 11 = @tuple_typeexpr +| 12 = @keyof_typeexpr +| 13 = @qualified_type_access +| 14 = @generic_typeexpr +| 15 = @type_label +| 16 = @typeof_typeexpr +| 17 = @local_var_type_access +| 18 = @qualified_var_type_access +| 19 = @this_var_type_access +| 20 = @predicate_typeexpr +| 21 = @interface_typeexpr +| 22 = @type_parameter +| 23 = @plain_function_typeexpr +| 24 = @constructor_typeexpr +| 25 = @local_namespace_access +| 26 = @qualified_namespace_access +| 27 = @mapped_typeexpr +| 28 = @conditional_typeexpr +| 29 = @infer_typeexpr +| 30 = @import_type_access +| 31 = @import_namespace_access +| 32 = @import_var_type_access +| 33 = @optional_typeexpr +| 34 = @rest_typeexpr +| 35 = @bigint_literal_typeexpr +| 36 = @readonly_typeexpr +| 37 = @template_literal_typeexpr +; + +@typeref = @typeaccess | @type_decl; +@type_identifier = @type_decl | @local_type_access | @type_label | @local_var_type_access | @local_namespace_access; +@typeexpr_parent = @expr | @stmt | @property | @typeexpr; +@literal_typeexpr = @string_literal_typeexpr | @number_literal_typeexpr | @boolean_literal_typeexpr | @bigint_literal_typeexpr; +@typeaccess = @local_type_access | @qualified_type_access | @import_type_access; +@vartypeaccess = @local_var_type_access | @qualified_var_type_access | @this_var_type_access | @import_var_type_access; +@namespace_access = @local_namespace_access | @qualified_namespace_access | @import_namespace_access; +@import_typeexpr = @import_type_access | @import_namespace_access | @import_var_type_access; + +@function_typeexpr = @plain_function_typeexpr | @constructor_typeexpr; + +// types +types ( + unique int id: @type, + int kind: int ref, + varchar(900) tostring: string ref +); + +#keyset[parent, idx] +type_child ( + int child: @type ref, + int parent: @type ref, + int idx: int ref +); + +case @type.kind of + 0 = @any_type +| 1 = @string_type +| 2 = @number_type +| 3 = @union_type +| 4 = @true_type +| 5 = @false_type +| 6 = @type_reference +| 7 = @object_type +| 8 = @canonical_type_variable_type +| 9 = @typeof_type +| 10 = @void_type +| 11 = @undefined_type +| 12 = @null_type +| 13 = @never_type +| 14 = @plain_symbol_type +| 15 = @unique_symbol_type +| 16 = @objectkeyword_type +| 17 = @intersection_type +| 18 = @tuple_type +| 19 = @lexical_type_variable_type +| 20 = @this_type +| 21 = @number_literal_type +| 22 = @string_literal_type +| 23 = @unknown_type +| 24 = @bigint_type +| 25 = @bigint_literal_type +; + +@boolean_literal_type = @true_type | @false_type; +@symbol_type = @plain_symbol_type | @unique_symbol_type; +@union_or_intersection_type = @union_type | @intersection_type; +@typevariable_type = @canonical_type_variable_type | @lexical_type_variable_type; + +has_asserts_keyword(int node: @predicate_typeexpr ref); + +@typed_ast_node = @expr | @typeexpr | @function; +ast_node_type( + unique int node: @typed_ast_node ref, + int typ: @type ref); + +declared_function_signature( + unique int node: @function ref, + int sig: @signature_type ref +); + +invoke_expr_signature( + unique int node: @invokeexpr ref, + int sig: @signature_type ref +); + +invoke_expr_overload_index( + unique int node: @invokeexpr ref, + int index: int ref +); + +symbols ( + unique int id: @symbol, + int kind: int ref, + varchar(900) name: string ref +); + +symbol_parent ( + unique int symbol: @symbol ref, + int parent: @symbol ref +); + +symbol_module ( + int symbol: @symbol ref, + varchar(900) moduleName: string ref +); + +symbol_global ( + int symbol: @symbol ref, + varchar(900) globalName: string ref +); + +case @symbol.kind of + 0 = @root_symbol +| 1 = @member_symbol +| 2 = @other_symbol +; + +@type_with_symbol = @type_reference | @typevariable_type | @typeof_type | @unique_symbol_type; +@ast_node_with_symbol = @type_definition | @namespace_definition | @toplevel | @typeaccess | @namespace_access | @var_decl | @function | @invokeexpr | @import_declaration | @external_module_reference; + +ast_node_symbol( + unique int node: @ast_node_with_symbol ref, + int symbol: @symbol ref); + +type_symbol( + unique int typ: @type_with_symbol ref, + int symbol: @symbol ref); + +#keyset[typ, name] +type_property( + int typ: @type ref, + varchar(900) name: string ref, + int propertyType: @type ref); + +type_alias( + unique int aliasType: @type ref, + int underlyingType: @type ref); + +@literal_type = @string_literal_type | @number_literal_type | @boolean_literal_type | @bigint_literal_type; +@type_with_literal_value = @string_literal_type | @number_literal_type | @bigint_literal_type; +type_literal_value( + unique int typ: @type_with_literal_value ref, + varchar(900) value: string ref); + +signature_types ( + unique int id: @signature_type, + int kind: int ref, + varchar(900) tostring: string ref, + int type_parameters: int ref, + int required_params: int ref +); + +is_abstract_signature( + unique int sig: @signature_type ref +); + +signature_rest_parameter( + unique int sig: @signature_type ref, + int rest_param_arra_type: @type ref +); + +case @signature_type.kind of + 0 = @function_signature_type +| 1 = @constructor_signature_type +; + +#keyset[typ, kind, index] +type_contains_signature ( + int typ: @type ref, + int kind: int ref, // constructor/call/index + int index: int ref, // ordering of overloaded signatures + int sig: @signature_type ref +); + +#keyset[parent, index] +signature_contains_type ( + int child: @type ref, + int parent: @signature_type ref, + int index: int ref +); + +#keyset[sig, index] +signature_parameter_name ( + int sig: @signature_type ref, + int index: int ref, + varchar(900) name: string ref +); + +number_index_type ( + unique int baseType: @type ref, + int propertyType: @type ref +); + +string_index_type ( + unique int baseType: @type ref, + int propertyType: @type ref +); + +base_type_names( + int typeName: @symbol ref, + int baseTypeName: @symbol ref +); + +self_types( + int typeName: @symbol ref, + int selfType: @type_reference ref +); + +tuple_type_min_length( + unique int typ: @type ref, + int minLength: int ref +); + +tuple_type_rest_index( + unique int typ: @type ref, + int index: int ref +); + +// comments +comments (unique int id: @comment, + int kind: int ref, + int toplevel: @toplevel ref, + varchar(900) text: string ref, + varchar(900) tostring: string ref); + +case @comment.kind of + 0 = @slashslash_comment +| 1 = @slashstar_comment +| 2 = @doc_comment +| 3 = @html_comment_start +| 4 = @htmlcommentend; + +@html_comment = @html_comment_start | @htmlcommentend; +@line_comment = @slashslash_comment | @html_comment; +@block_comment = @slashstar_comment | @doc_comment; + +// source lines +lines (unique int id: @line, + int toplevel: @toplevel ref, + varchar(900) text: string ref, + varchar(2) terminator: string ref); +indentation (int file: @file ref, + int lineno: int ref, + varchar(1) indentChar: string ref, + int indentDepth: int ref); + +// JavaScript parse errors +js_parse_errors (unique int id: @js_parse_error, + int toplevel: @toplevel ref, + varchar(900) message: string ref, + varchar(900) line: string ref); + +// regular expressions +#keyset[parent, idx] +regexpterm (unique int id: @regexpterm, + int kind: int ref, + int parent: @regexpparent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +@regexpparent = @regexpterm | @regexp_literal | @string_literal | @add_expr; + +case @regexpterm.kind of + 0 = @regexp_alt +| 1 = @regexp_seq +| 2 = @regexp_caret +| 3 = @regexp_dollar +| 4 = @regexp_wordboundary +| 5 = @regexp_nonwordboundary +| 6 = @regexp_positive_lookahead +| 7 = @regexp_negative_lookahead +| 8 = @regexp_star +| 9 = @regexp_plus +| 10 = @regexp_opt +| 11 = @regexp_range +| 12 = @regexp_dot +| 13 = @regexp_group +| 14 = @regexp_normal_constant +| 15 = @regexp_hex_escape +| 16 = @regexp_unicode_escape +| 17 = @regexp_dec_escape +| 18 = @regexp_oct_escape +| 19 = @regexp_ctrl_escape +| 20 = @regexp_char_class_escape +| 21 = @regexp_id_escape +| 22 = @regexp_backref +| 23 = @regexp_char_class +| 24 = @regexp_char_range +| 25 = @regexp_positive_lookbehind +| 26 = @regexp_negative_lookbehind +| 27 = @regexp_unicode_property_escape; + +regexp_parse_errors (unique int id: @regexp_parse_error, + int regexp: @regexpterm ref, + varchar(900) message: string ref); + +@regexp_quantifier = @regexp_star | @regexp_plus | @regexp_opt | @regexp_range; +@regexp_escape = @regexp_char_escape | @regexp_char_class_escape | @regexp_unicode_property_escape; +@regexp_char_escape = @regexp_hex_escape | @regexp_unicode_escape | @regexp_dec_escape | @regexp_oct_escape | @regexp_ctrl_escape | @regexp_id_escape; +@regexp_constant = @regexp_normal_constant | @regexp_char_escape; +@regexp_lookahead = @regexp_positive_lookahead | @regexp_negative_lookahead; +@regexp_lookbehind = @regexp_positive_lookbehind | @regexp_negative_lookbehind; +@regexp_subpattern = @regexp_lookahead | @regexp_lookbehind; +@regexp_anchor = @regexp_dollar | @regexp_caret; + +is_greedy (int id: @regexp_quantifier ref); +range_quantifier_lower_bound (unique int id: @regexp_range ref, int lo: int ref); +range_quantifier_upper_bound (unique int id: @regexp_range ref, int hi: int ref); +is_capture (unique int id: @regexp_group ref, int number: int ref); +is_named_capture (unique int id: @regexp_group ref, string name: string ref); +is_inverted (int id: @regexp_char_class ref); +regexp_const_value (unique int id: @regexp_constant ref, varchar(1) value: string ref); +char_class_escape (unique int id: @regexp_char_class_escape ref, varchar(1) value: string ref); +backref (unique int id: @regexp_backref ref, int value: int ref); +named_backref (unique int id: @regexp_backref ref, string name: string ref); +unicode_property_escapename (unique int id: @regexp_unicode_property_escape ref, string name: string ref); +unicode_property_escapevalue (unique int id: @regexp_unicode_property_escape ref, string value: string ref); + +// tokens +#keyset[toplevel, idx] +tokeninfo (unique int id: @token, + int kind: int ref, + int toplevel: @toplevel ref, + int idx: int ref, + varchar(900) value: string ref); + +case @token.kind of + 0 = @token_eof +| 1 = @token_null_literal +| 2 = @token_boolean_literal +| 3 = @token_numeric_literal +| 4 = @token_string_literal +| 5 = @token_regular_expression +| 6 = @token_identifier +| 7 = @token_keyword +| 8 = @token_punctuator; + +// associate comments with the token immediately following them (which may be EOF) +next_token (int comment: @comment ref, int token: @token ref); + +// JSON +#keyset[parent, idx] +json (unique int id: @json_value, + int kind: int ref, + int parent: @json_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +json_literals (varchar(900) value: string ref, + varchar(900) raw: string ref, + unique int expr: @json_value ref); + +json_properties (int obj: @json_object ref, + varchar(900) property: string ref, + int value: @json_value ref); + +json_errors (unique int id: @json_parse_error, + varchar(900) message: string ref); + +json_locations(unique int locatable: @json_locatable ref, + int location: @location_default ref); + +case @json_value.kind of + 0 = @json_null +| 1 = @json_boolean +| 2 = @json_number +| 3 = @json_string +| 4 = @json_array +| 5 = @json_object; + +@json_parent = @json_object | @json_array | @file; + +@json_locatable = @json_value | @json_parse_error; + +// locations +@ast_node = @toplevel | @stmt | @expr | @property | @typeexpr; + +@locatable = @file + | @ast_node + | @comment + | @line + | @js_parse_error | @regexp_parse_error + | @regexpterm + | @json_locatable + | @token + | @cfg_node + | @jsdoc | @jsdoc_type_expr | @jsdoc_tag + | @yaml_locatable + | @xmllocatable + | @configLocatable + | @template_placeholder_tag; + +hasLocation (unique int locatable: @locatable ref, + int location: @location ref); + +// CFG +entry_cfg_node (unique int id: @entry_node, int container: @stmt_container ref); +exit_cfg_node (unique int id: @exit_node, int container: @stmt_container ref); +guard_node (unique int id: @guard_node, int kind: int ref, int test: @expr ref); +case @guard_node.kind of + 0 = @falsy_guard +| 1 = @truthy_guard; +@condition_guard = @falsy_guard | @truthy_guard; + +@synthetic_cfg_node = @entry_node | @exit_node | @guard_node; +@cfg_node = @synthetic_cfg_node | @expr_parent; + +successor (int pred: @cfg_node ref, int succ: @cfg_node ref); + +// JSDoc comments +jsdoc (unique int id: @jsdoc, varchar(900) description: string ref, int comment: @comment ref); +#keyset[parent, idx] +jsdoc_tags (unique int id: @jsdoc_tag, varchar(900) title: string ref, + int parent: @jsdoc ref, int idx: int ref, varchar(900) tostring: string ref); +jsdoc_tag_descriptions (unique int tag: @jsdoc_tag ref, varchar(900) text: string ref); +jsdoc_tag_names (unique int tag: @jsdoc_tag ref, varchar(900) text: string ref); + +#keyset[parent, idx] +jsdoc_type_exprs (unique int id: @jsdoc_type_expr, + int kind: int ref, + int parent: @jsdoc_type_expr_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); +case @jsdoc_type_expr.kind of + 0 = @jsdoc_any_type_expr +| 1 = @jsdoc_null_type_expr +| 2 = @jsdoc_undefined_type_expr +| 3 = @jsdoc_unknown_type_expr +| 4 = @jsdoc_void_type_expr +| 5 = @jsdoc_named_type_expr +| 6 = @jsdoc_applied_type_expr +| 7 = @jsdoc_nullable_type_expr +| 8 = @jsdoc_non_nullable_type_expr +| 9 = @jsdoc_record_type_expr +| 10 = @jsdoc_array_type_expr +| 11 = @jsdoc_union_type_expr +| 12 = @jsdoc_function_type_expr +| 13 = @jsdoc_optional_type_expr +| 14 = @jsdoc_rest_type_expr +; + +#keyset[id, idx] +jsdoc_record_field_name (int id: @jsdoc_record_type_expr ref, int idx: int ref, varchar(900) name: string ref); +jsdoc_prefix_qualifier (int id: @jsdoc_type_expr ref); +jsdoc_has_new_parameter (int fn: @jsdoc_function_type_expr ref); + +@jsdoc_type_expr_parent = @jsdoc_type_expr | @jsdoc_tag; + +jsdoc_errors (unique int id: @jsdoc_error, int tag: @jsdoc_tag ref, varchar(900) message: string ref, varchar(900) tostring: string ref); + +// YAML +#keyset[parent, idx] +yaml (unique int id: @yaml_node, + int kind: int ref, + int parent: @yaml_node_parent ref, + int idx: int ref, + varchar(900) tag: string ref, + varchar(900) tostring: string ref); + +case @yaml_node.kind of + 0 = @yaml_scalar_node +| 1 = @yaml_mapping_node +| 2 = @yaml_sequence_node +| 3 = @yaml_alias_node +; + +@yaml_collection_node = @yaml_mapping_node | @yaml_sequence_node; + +@yaml_node_parent = @yaml_collection_node | @file; + +yaml_anchors (unique int node: @yaml_node ref, + varchar(900) anchor: string ref); + +yaml_aliases (unique int alias: @yaml_alias_node ref, + varchar(900) target: string ref); + +yaml_scalars (unique int scalar: @yaml_scalar_node ref, + int style: int ref, + varchar(900) value: string ref); + +yaml_errors (unique int id: @yaml_error, + varchar(900) message: string ref); + +yaml_locations(unique int locatable: @yaml_locatable ref, + int location: @location_default ref); + +@yaml_locatable = @yaml_node | @yaml_error; + +/* XML Files */ + +xmlEncoding( + unique int id: @file ref, + varchar(900) encoding: string ref +); + +xmlDTDs( + unique int id: @xmldtd, + varchar(900) root: string ref, + varchar(900) publicId: string ref, + varchar(900) systemId: string ref, + int fileid: @file ref +); + +xmlElements( + unique int id: @xmlelement, + varchar(900) name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref +); + +xmlAttrs( + unique int id: @xmlattribute, + int elementid: @xmlelement ref, + varchar(900) name: string ref, + varchar(3600) value: string ref, + int idx: int ref, + int fileid: @file ref +); + +xmlNs( + int id: @xmlnamespace, + varchar(900) prefixName: string ref, + varchar(900) URI: string ref, + int fileid: @file ref +); + +xmlHasNs( + int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref +); + +xmlComments( + unique int id: @xmlcomment, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref +); + +xmlChars( + unique int id: @xmlcharacters, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref +); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations( + int xmlElement: @xmllocatable ref, + int location: @location_default ref +); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; + +@dataflownode = @expr | @function_decl_stmt | @class_decl_stmt | @namespace_declaration | @enum_declaration | @property; + +@optionalchainable = @call_expr | @propaccess; + +isOptionalChaining(int id: @optionalchainable ref); + +/* + * configuration files with key value pairs + */ + +configs( + unique int id: @config +); + +configNames( + unique int id: @configName, + int config: @config ref, + string name: string ref +); + +configValues( + unique int id: @configValue, + int config: @config ref, + string value: string ref +); + +configLocations( + int locatable: @configLocatable ref, + int location: @location_default ref +); + +@configLocatable = @config | @configName | @configValue; + +/** + * The time taken for the extraction of a file. + * This table contains non-deterministic content. + * + * The sum of the `time` column for each (`file`, `timerKind`) pair + * is the total time taken for extraction of `file`. The `extractionPhase` + * column provides a granular view of the extraction time of the file. + */ +extraction_time( + int file : @file ref, + // see `com.semmle.js.extractor.ExtractionMetrics.ExtractionPhase`. + int extractionPhase: int ref, + // 0 for the elapsed CPU time in nanoseconds, 1 for the elapsed wallclock time in nanoseconds + int timerKind: int ref, + float time: float ref +) + +/** + * Non-timing related data for the extraction of a single file. + * This table contains non-deterministic content. + */ +extraction_data( + int file : @file ref, + // the absolute path to the cache file + varchar(900) cacheFile: string ref, + boolean fromCache: boolean ref, + int length: int ref +) diff --git a/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/semmlecode.javascript.dbscheme b/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/semmlecode.javascript.dbscheme new file mode 100644 index 00000000000..c1ee5346e06 --- /dev/null +++ b/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/semmlecode.javascript.dbscheme @@ -0,0 +1,1217 @@ +/*** Standard fragments ***/ + +/** Files and folders **/ + +@location = @location_default; + +locations_default(unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref + ); + +@sourceline = @locatable; + +numlines(int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref + ); + +files(unique int id: @file, + varchar(900) name: string ref); + +folders(unique int id: @folder, + varchar(900) name: string ref); + + +@container = @folder | @file ; + + +containerparent(int parent: @container ref, + unique int child: @container ref); + +/** Duplicate code **/ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity; + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/** External data **/ + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +/** Version control data **/ + +svnentries( + int id : @svnentry, + varchar(500) revision : string ref, + varchar(500) author : string ref, + date revisionDate : date ref, + int changeSize : int ref +); + +svnaffectedfiles( + int id : @svnentry ref, + int file : @file ref, + varchar(500) action : string ref +); + +svnentrymsg( + int id : @svnentry ref, + varchar(500) message : string ref +); + +svnchurn( + int commit : @svnentry ref, + int file : @file ref, + int addedLines : int ref, + int deletedLines : int ref +); + + +/*** JavaScript-specific part ***/ + +filetype( + int file: @file ref, + string filetype: string ref +) + +// top-level code fragments +toplevels (unique int id: @toplevel, + int kind: int ref); + +is_externs (int toplevel: @toplevel ref); + +case @toplevel.kind of + 0 = @script +| 1 = @inline_script +| 2 = @event_handler +| 3 = @javascript_url +| 4 = @template_toplevel; + +is_module (int tl: @toplevel ref); +is_nodejs (int tl: @toplevel ref); +is_es2015_module (int tl: @toplevel ref); +is_closure_module (int tl: @toplevel ref); + +@xml_node_with_code = @xmlelement | @xmlattribute | @template_placeholder_tag; +toplevel_parent_xml_node( + unique int toplevel: @toplevel ref, + int xmlnode: @xml_node_with_code ref); + +xml_element_parent_expression( + unique int xmlnode: @xmlelement ref, + int expression: @expr ref, + int index: int ref); + +// statements +#keyset[parent, idx] +stmts (unique int id: @stmt, + int kind: int ref, + int parent: @stmt_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +stmt_containers (unique int stmt: @stmt ref, + int container: @stmt_container ref); + +jump_targets (unique int jump: @stmt ref, + int target: @stmt ref); + +@stmt_parent = @stmt | @toplevel | @function_expr | @arrow_function_expr | @static_initializer; +@stmt_container = @toplevel | @function | @namespace_declaration | @external_module_declaration | @global_augmentation_declaration; + +case @stmt.kind of + 0 = @empty_stmt +| 1 = @block_stmt +| 2 = @expr_stmt +| 3 = @if_stmt +| 4 = @labeled_stmt +| 5 = @break_stmt +| 6 = @continue_stmt +| 7 = @with_stmt +| 8 = @switch_stmt +| 9 = @return_stmt +| 10 = @throw_stmt +| 11 = @try_stmt +| 12 = @while_stmt +| 13 = @do_while_stmt +| 14 = @for_stmt +| 15 = @for_in_stmt +| 16 = @debugger_stmt +| 17 = @function_decl_stmt +| 18 = @var_decl_stmt +| 19 = @case +| 20 = @catch_clause +| 21 = @for_of_stmt +| 22 = @const_decl_stmt +| 23 = @let_stmt +| 24 = @legacy_let_stmt +| 25 = @for_each_stmt +| 26 = @class_decl_stmt +| 27 = @import_declaration +| 28 = @export_all_declaration +| 29 = @export_default_declaration +| 30 = @export_named_declaration +| 31 = @namespace_declaration +| 32 = @import_equals_declaration +| 33 = @export_assign_declaration +| 34 = @interface_declaration +| 35 = @type_alias_declaration +| 36 = @enum_declaration +| 37 = @external_module_declaration +| 38 = @export_as_namespace_declaration +| 39 = @global_augmentation_declaration +; + +@decl_stmt = @var_decl_stmt | @const_decl_stmt | @let_stmt | @legacy_let_stmt; + +@export_declaration = @export_all_declaration | @export_default_declaration | @export_named_declaration; + +@namespace_definition = @namespace_declaration | @enum_declaration; +@type_definition = @class_definition | @interface_declaration | @enum_declaration | @type_alias_declaration | @enum_member; + +is_instantiated(unique int decl: @namespace_declaration ref); + +@declarable_node = @decl_stmt | @namespace_declaration | @class_decl_stmt | @function_decl_stmt | @enum_declaration | @external_module_declaration | @global_augmentation_declaration | @field; +has_declare_keyword(unique int stmt: @declarable_node ref); + +is_for_await_of(unique int forof: @for_of_stmt ref); + +// expressions +#keyset[parent, idx] +exprs (unique int id: @expr, + int kind: int ref, + int parent: @expr_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +literals (varchar(900) value: string ref, + varchar(900) raw: string ref, + unique int expr: @expr_or_type ref); + +enclosing_stmt (unique int expr: @expr_or_type ref, + int stmt: @stmt ref); + +expr_containers (unique int expr: @expr_or_type ref, + int container: @stmt_container ref); + +array_size (unique int ae: @arraylike ref, + int sz: int ref); + +is_delegating (int yield: @yield_expr ref); + +@expr_or_stmt = @expr | @stmt; +@expr_or_type = @expr | @typeexpr; +@expr_parent = @expr_or_stmt | @property | @function_typeexpr; +@arraylike = @array_expr | @array_pattern; +@type_annotation = @typeexpr | @jsdoc_type_expr; +@node_in_stmt_container = @cfg_node | @type_annotation | @toplevel; + +case @expr.kind of + 0 = @label +| 1 = @null_literal +| 2 = @boolean_literal +| 3 = @number_literal +| 4 = @string_literal +| 5 = @regexp_literal +| 6 = @this_expr +| 7 = @array_expr +| 8 = @obj_expr +| 9 = @function_expr +| 10 = @seq_expr +| 11 = @conditional_expr +| 12 = @new_expr +| 13 = @call_expr +| 14 = @dot_expr +| 15 = @index_expr +| 16 = @neg_expr +| 17 = @plus_expr +| 18 = @log_not_expr +| 19 = @bit_not_expr +| 20 = @typeof_expr +| 21 = @void_expr +| 22 = @delete_expr +| 23 = @eq_expr +| 24 = @neq_expr +| 25 = @eqq_expr +| 26 = @neqq_expr +| 27 = @lt_expr +| 28 = @le_expr +| 29 = @gt_expr +| 30 = @ge_expr +| 31 = @lshift_expr +| 32 = @rshift_expr +| 33 = @urshift_expr +| 34 = @add_expr +| 35 = @sub_expr +| 36 = @mul_expr +| 37 = @div_expr +| 38 = @mod_expr +| 39 = @bitor_expr +| 40 = @xor_expr +| 41 = @bitand_expr +| 42 = @in_expr +| 43 = @instanceof_expr +| 44 = @logand_expr +| 45 = @logor_expr +| 47 = @assign_expr +| 48 = @assign_add_expr +| 49 = @assign_sub_expr +| 50 = @assign_mul_expr +| 51 = @assign_div_expr +| 52 = @assign_mod_expr +| 53 = @assign_lshift_expr +| 54 = @assign_rshift_expr +| 55 = @assign_urshift_expr +| 56 = @assign_or_expr +| 57 = @assign_xor_expr +| 58 = @assign_and_expr +| 59 = @preinc_expr +| 60 = @postinc_expr +| 61 = @predec_expr +| 62 = @postdec_expr +| 63 = @par_expr +| 64 = @var_declarator +| 65 = @arrow_function_expr +| 66 = @spread_element +| 67 = @array_pattern +| 68 = @object_pattern +| 69 = @yield_expr +| 70 = @tagged_template_expr +| 71 = @template_literal +| 72 = @template_element +| 73 = @array_comprehension_expr +| 74 = @generator_expr +| 75 = @for_in_comprehension_block +| 76 = @for_of_comprehension_block +| 77 = @legacy_letexpr +| 78 = @var_decl +| 79 = @proper_varaccess +| 80 = @class_expr +| 81 = @super_expr +| 82 = @newtarget_expr +| 83 = @named_import_specifier +| 84 = @import_default_specifier +| 85 = @import_namespace_specifier +| 86 = @named_export_specifier +| 87 = @exp_expr +| 88 = @assign_exp_expr +| 89 = @jsx_element +| 90 = @jsx_qualified_name +| 91 = @jsx_empty_expr +| 92 = @await_expr +| 93 = @function_sent_expr +| 94 = @decorator +| 95 = @export_default_specifier +| 96 = @export_namespace_specifier +| 97 = @bind_expr +| 98 = @external_module_reference +| 99 = @dynamic_import +| 100 = @expression_with_type_arguments +| 101 = @prefix_type_assertion +| 102 = @as_type_assertion +| 103 = @export_varaccess +| 104 = @decorator_list +| 105 = @non_null_assertion +| 106 = @bigint_literal +| 107 = @nullishcoalescing_expr +| 108 = @e4x_xml_anyname +| 109 = @e4x_xml_static_attribute_selector +| 110 = @e4x_xml_dynamic_attribute_selector +| 111 = @e4x_xml_filter_expression +| 112 = @e4x_xml_static_qualident +| 113 = @e4x_xml_dynamic_qualident +| 114 = @e4x_xml_dotdotexpr +| 115 = @import_meta_expr +| 116 = @assignlogandexpr +| 117 = @assignlogorexpr +| 118 = @assignnullishcoalescingexpr +| 119 = @template_pipe_ref +| 120 = @generated_code_expr +; + +@varaccess = @proper_varaccess | @export_varaccess; +@varref = @var_decl | @varaccess; + +@identifier = @label | @varref | @type_identifier; + +@literal = @null_literal | @boolean_literal | @number_literal | @string_literal | @regexp_literal | @bigint_literal; + +@propaccess = @dot_expr | @index_expr; + +@invokeexpr = @new_expr | @call_expr; + +@unaryexpr = @neg_expr | @plus_expr | @log_not_expr | @bit_not_expr | @typeof_expr | @void_expr | @delete_expr | @spread_element; + +@equality_test = @eq_expr | @neq_expr | @eqq_expr | @neqq_expr; + +@comparison = @equality_test | @lt_expr | @le_expr | @gt_expr | @ge_expr; + +@binaryexpr = @comparison | @lshift_expr | @rshift_expr | @urshift_expr | @add_expr | @sub_expr | @mul_expr | @div_expr | @mod_expr | @exp_expr | @bitor_expr | @xor_expr | @bitand_expr | @in_expr | @instanceof_expr | @logand_expr | @logor_expr | @nullishcoalescing_expr; + +@assignment = @assign_expr | @assign_add_expr | @assign_sub_expr | @assign_mul_expr | @assign_div_expr | @assign_mod_expr | @assign_exp_expr | @assign_lshift_expr | @assign_rshift_expr | @assign_urshift_expr | @assign_or_expr | @assign_xor_expr | @assign_and_expr | @assignlogandexpr | @assignlogorexpr | @assignnullishcoalescingexpr; + +@updateexpr = @preinc_expr | @postinc_expr | @predec_expr | @postdec_expr; + +@pattern = @varref | @array_pattern | @object_pattern; + +@comprehension_expr = @array_comprehension_expr | @generator_expr; + +@comprehension_block = @for_in_comprehension_block | @for_of_comprehension_block; + +@import_specifier = @named_import_specifier | @import_default_specifier | @import_namespace_specifier; + +@exportspecifier = @named_export_specifier | @export_default_specifier | @export_namespace_specifier; + +@type_keyword_operand = @import_declaration | @export_declaration | @import_specifier; + +@type_assertion = @as_type_assertion | @prefix_type_assertion; + +@class_definition = @class_decl_stmt | @class_expr; +@interface_definition = @interface_declaration | @interface_typeexpr; +@class_or_interface = @class_definition | @interface_definition; + +@lexical_decl = @var_decl | @type_decl; +@lexical_access = @varaccess | @local_type_access | @local_var_type_access | @local_namespace_access; +@lexical_ref = @lexical_decl | @lexical_access; + +@e4x_xml_attribute_selector = @e4x_xml_static_attribute_selector | @e4x_xml_dynamic_attribute_selector; +@e4x_xml_qualident = @e4x_xml_static_qualident | @e4x_xml_dynamic_qualident; + +expr_contains_template_tag_location( + int expr: @expr ref, + int location: @location ref +); + +@template_placeholder_tag_parent = @xmlelement | @xmlattribute | @file; + +template_placeholder_tag_info( + unique int node: @template_placeholder_tag, + int parentNode: @template_placeholder_tag_parent ref, + varchar(900) raw: string ref +); + +// scopes +scopes (unique int id: @scope, + int kind: int ref); + +case @scope.kind of + 0 = @global_scope +| 1 = @function_scope +| 2 = @catch_scope +| 3 = @module_scope +| 4 = @block_scope +| 5 = @for_scope +| 6 = @for_in_scope // for-of scopes work the same as for-in scopes +| 7 = @comprehension_block_scope +| 8 = @class_expr_scope +| 9 = @namespace_scope +| 10 = @class_decl_scope +| 11 = @interface_scope +| 12 = @type_alias_scope +| 13 = @mapped_type_scope +| 14 = @enum_scope +| 15 = @external_module_scope +| 16 = @conditional_type_scope; + +scopenodes (unique int node: @ast_node ref, + int scope: @scope ref); + +scopenesting (unique int inner: @scope ref, + int outer: @scope ref); + +// functions +@function = @function_decl_stmt | @function_expr | @arrow_function_expr; + +@parameterized = @function | @catch_clause; +@type_parameterized = @function | @class_or_interface | @type_alias_declaration | @mapped_typeexpr | @infer_typeexpr; + +is_generator (int fun: @function ref); +has_rest_parameter (int fun: @function ref); +is_async (int fun: @function ref); + +// variables and lexically scoped type names +#keyset[scope, name] +variables (unique int id: @variable, + varchar(900) name: string ref, + int scope: @scope ref); + +#keyset[scope, name] +local_type_names (unique int id: @local_type_name, + varchar(900) name: string ref, + int scope: @scope ref); + +#keyset[scope, name] +local_namespace_names (unique int id: @local_namespace_name, + varchar(900) name: string ref, + int scope: @scope ref); + +is_arguments_object (int id: @variable ref); + +@lexical_name = @variable | @local_type_name | @local_namespace_name; + +@bind_id = @varaccess | @local_var_type_access; +bind (unique int id: @bind_id ref, + int decl: @variable ref); + +decl (unique int id: @var_decl ref, + int decl: @variable ref); + +@typebind_id = @local_type_access | @export_varaccess; +typebind (unique int id: @typebind_id ref, + int decl: @local_type_name ref); + +@typedecl_id = @type_decl | @var_decl; +typedecl (unique int id: @typedecl_id ref, + int decl: @local_type_name ref); + +namespacedecl (unique int id: @var_decl ref, + int decl: @local_namespace_name ref); + +@namespacebind_id = @local_namespace_access | @export_varaccess; +namespacebind (unique int id: @namespacebind_id ref, + int decl: @local_namespace_name ref); + + +// properties in object literals, property patterns in object patterns, and method declarations in classes +#keyset[parent, index] +properties (unique int id: @property, + int parent: @property_parent ref, + int index: int ref, + int kind: int ref, + varchar(900) tostring: string ref); + +case @property.kind of + 0 = @value_property +| 1 = @property_getter +| 2 = @property_setter +| 3 = @jsx_attribute +| 4 = @function_call_signature +| 5 = @constructor_call_signature +| 6 = @index_signature +| 7 = @enum_member +| 8 = @proper_field +| 9 = @parameter_field +| 10 = @static_initializer +; + +@property_parent = @obj_expr | @object_pattern | @class_definition | @jsx_element | @interface_definition | @enum_declaration; +@property_accessor = @property_getter | @property_setter; +@call_signature = @function_call_signature | @constructor_call_signature; +@field = @proper_field | @parameter_field; +@field_or_vardeclarator = @field | @var_declarator; + +is_computed (int id: @property ref); +is_method (int id: @property ref); +is_static (int id: @property ref); +is_abstract_member (int id: @property ref); +is_const_enum (int id: @enum_declaration ref); +is_abstract_class (int id: @class_decl_stmt ref); + +has_public_keyword (int id: @property ref); +has_private_keyword (int id: @property ref); +has_protected_keyword (int id: @property ref); +has_readonly_keyword (int id: @property ref); +has_type_keyword (int id: @type_keyword_operand ref); +is_optional_member (int id: @property ref); +has_definite_assignment_assertion (int id: @field_or_vardeclarator ref); +is_optional_parameter_declaration (unique int parameter: @pattern ref); + +#keyset[constructor, param_index] +parameter_fields( + unique int field: @parameter_field ref, + int constructor: @function_expr ref, + int param_index: int ref +); + +// types +#keyset[parent, idx] +typeexprs ( + unique int id: @typeexpr, + int kind: int ref, + int parent: @typeexpr_parent ref, + int idx: int ref, + varchar(900) tostring: string ref +); + +case @typeexpr.kind of + 0 = @local_type_access +| 1 = @type_decl +| 2 = @keyword_typeexpr +| 3 = @string_literal_typeexpr +| 4 = @number_literal_typeexpr +| 5 = @boolean_literal_typeexpr +| 6 = @array_typeexpr +| 7 = @union_typeexpr +| 8 = @indexed_access_typeexpr +| 9 = @intersection_typeexpr +| 10 = @parenthesized_typeexpr +| 11 = @tuple_typeexpr +| 12 = @keyof_typeexpr +| 13 = @qualified_type_access +| 14 = @generic_typeexpr +| 15 = @type_label +| 16 = @typeof_typeexpr +| 17 = @local_var_type_access +| 18 = @qualified_var_type_access +| 19 = @this_var_type_access +| 20 = @predicate_typeexpr +| 21 = @interface_typeexpr +| 22 = @type_parameter +| 23 = @plain_function_typeexpr +| 24 = @constructor_typeexpr +| 25 = @local_namespace_access +| 26 = @qualified_namespace_access +| 27 = @mapped_typeexpr +| 28 = @conditional_typeexpr +| 29 = @infer_typeexpr +| 30 = @import_type_access +| 31 = @import_namespace_access +| 32 = @import_var_type_access +| 33 = @optional_typeexpr +| 34 = @rest_typeexpr +| 35 = @bigint_literal_typeexpr +| 36 = @readonly_typeexpr +| 37 = @template_literal_typeexpr +; + +@typeref = @typeaccess | @type_decl; +@type_identifier = @type_decl | @local_type_access | @type_label | @local_var_type_access | @local_namespace_access; +@typeexpr_parent = @expr | @stmt | @property | @typeexpr; +@literal_typeexpr = @string_literal_typeexpr | @number_literal_typeexpr | @boolean_literal_typeexpr | @bigint_literal_typeexpr; +@typeaccess = @local_type_access | @qualified_type_access | @import_type_access; +@vartypeaccess = @local_var_type_access | @qualified_var_type_access | @this_var_type_access | @import_var_type_access; +@namespace_access = @local_namespace_access | @qualified_namespace_access | @import_namespace_access; +@import_typeexpr = @import_type_access | @import_namespace_access | @import_var_type_access; + +@function_typeexpr = @plain_function_typeexpr | @constructor_typeexpr; + +// types +types ( + unique int id: @type, + int kind: int ref, + varchar(900) tostring: string ref +); + +#keyset[parent, idx] +type_child ( + int child: @type ref, + int parent: @type ref, + int idx: int ref +); + +case @type.kind of + 0 = @any_type +| 1 = @string_type +| 2 = @number_type +| 3 = @union_type +| 4 = @true_type +| 5 = @false_type +| 6 = @type_reference +| 7 = @object_type +| 8 = @canonical_type_variable_type +| 9 = @typeof_type +| 10 = @void_type +| 11 = @undefined_type +| 12 = @null_type +| 13 = @never_type +| 14 = @plain_symbol_type +| 15 = @unique_symbol_type +| 16 = @objectkeyword_type +| 17 = @intersection_type +| 18 = @tuple_type +| 19 = @lexical_type_variable_type +| 20 = @this_type +| 21 = @number_literal_type +| 22 = @string_literal_type +| 23 = @unknown_type +| 24 = @bigint_type +| 25 = @bigint_literal_type +; + +@boolean_literal_type = @true_type | @false_type; +@symbol_type = @plain_symbol_type | @unique_symbol_type; +@union_or_intersection_type = @union_type | @intersection_type; +@typevariable_type = @canonical_type_variable_type | @lexical_type_variable_type; + +has_asserts_keyword(int node: @predicate_typeexpr ref); + +@typed_ast_node = @expr | @typeexpr | @function; +ast_node_type( + unique int node: @typed_ast_node ref, + int typ: @type ref); + +declared_function_signature( + unique int node: @function ref, + int sig: @signature_type ref +); + +invoke_expr_signature( + unique int node: @invokeexpr ref, + int sig: @signature_type ref +); + +invoke_expr_overload_index( + unique int node: @invokeexpr ref, + int index: int ref +); + +symbols ( + unique int id: @symbol, + int kind: int ref, + varchar(900) name: string ref +); + +symbol_parent ( + unique int symbol: @symbol ref, + int parent: @symbol ref +); + +symbol_module ( + int symbol: @symbol ref, + varchar(900) moduleName: string ref +); + +symbol_global ( + int symbol: @symbol ref, + varchar(900) globalName: string ref +); + +case @symbol.kind of + 0 = @root_symbol +| 1 = @member_symbol +| 2 = @other_symbol +; + +@type_with_symbol = @type_reference | @typevariable_type | @typeof_type | @unique_symbol_type; +@ast_node_with_symbol = @type_definition | @namespace_definition | @toplevel | @typeaccess | @namespace_access | @var_decl | @function | @invokeexpr | @import_declaration | @external_module_reference; + +ast_node_symbol( + unique int node: @ast_node_with_symbol ref, + int symbol: @symbol ref); + +type_symbol( + unique int typ: @type_with_symbol ref, + int symbol: @symbol ref); + +#keyset[typ, name] +type_property( + int typ: @type ref, + varchar(900) name: string ref, + int propertyType: @type ref); + +type_alias( + unique int aliasType: @type ref, + int underlyingType: @type ref); + +@literal_type = @string_literal_type | @number_literal_type | @boolean_literal_type | @bigint_literal_type; +@type_with_literal_value = @string_literal_type | @number_literal_type | @bigint_literal_type; +type_literal_value( + unique int typ: @type_with_literal_value ref, + varchar(900) value: string ref); + +signature_types ( + unique int id: @signature_type, + int kind: int ref, + varchar(900) tostring: string ref, + int type_parameters: int ref, + int required_params: int ref +); + +is_abstract_signature( + unique int sig: @signature_type ref +); + +signature_rest_parameter( + unique int sig: @signature_type ref, + int rest_param_arra_type: @type ref +); + +case @signature_type.kind of + 0 = @function_signature_type +| 1 = @constructor_signature_type +; + +#keyset[typ, kind, index] +type_contains_signature ( + int typ: @type ref, + int kind: int ref, // constructor/call/index + int index: int ref, // ordering of overloaded signatures + int sig: @signature_type ref +); + +#keyset[parent, index] +signature_contains_type ( + int child: @type ref, + int parent: @signature_type ref, + int index: int ref +); + +#keyset[sig, index] +signature_parameter_name ( + int sig: @signature_type ref, + int index: int ref, + varchar(900) name: string ref +); + +number_index_type ( + unique int baseType: @type ref, + int propertyType: @type ref +); + +string_index_type ( + unique int baseType: @type ref, + int propertyType: @type ref +); + +base_type_names( + int typeName: @symbol ref, + int baseTypeName: @symbol ref +); + +self_types( + int typeName: @symbol ref, + int selfType: @type_reference ref +); + +tuple_type_min_length( + unique int typ: @type ref, + int minLength: int ref +); + +tuple_type_rest_index( + unique int typ: @type ref, + int index: int ref +); + +// comments +comments (unique int id: @comment, + int kind: int ref, + int toplevel: @toplevel ref, + varchar(900) text: string ref, + varchar(900) tostring: string ref); + +case @comment.kind of + 0 = @slashslash_comment +| 1 = @slashstar_comment +| 2 = @doc_comment +| 3 = @html_comment_start +| 4 = @htmlcommentend; + +@html_comment = @html_comment_start | @htmlcommentend; +@line_comment = @slashslash_comment | @html_comment; +@block_comment = @slashstar_comment | @doc_comment; + +// source lines +lines (unique int id: @line, + int toplevel: @toplevel ref, + varchar(900) text: string ref, + varchar(2) terminator: string ref); +indentation (int file: @file ref, + int lineno: int ref, + varchar(1) indentChar: string ref, + int indentDepth: int ref); + +// JavaScript parse errors +js_parse_errors (unique int id: @js_parse_error, + int toplevel: @toplevel ref, + varchar(900) message: string ref, + varchar(900) line: string ref); + +// regular expressions +#keyset[parent, idx] +regexpterm (unique int id: @regexpterm, + int kind: int ref, + int parent: @regexpparent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +@regexpparent = @regexpterm | @regexp_literal | @string_literal | @add_expr; + +case @regexpterm.kind of + 0 = @regexp_alt +| 1 = @regexp_seq +| 2 = @regexp_caret +| 3 = @regexp_dollar +| 4 = @regexp_wordboundary +| 5 = @regexp_nonwordboundary +| 6 = @regexp_positive_lookahead +| 7 = @regexp_negative_lookahead +| 8 = @regexp_star +| 9 = @regexp_plus +| 10 = @regexp_opt +| 11 = @regexp_range +| 12 = @regexp_dot +| 13 = @regexp_group +| 14 = @regexp_normal_constant +| 15 = @regexp_hex_escape +| 16 = @regexp_unicode_escape +| 17 = @regexp_dec_escape +| 18 = @regexp_oct_escape +| 19 = @regexp_ctrl_escape +| 20 = @regexp_char_class_escape +| 21 = @regexp_id_escape +| 22 = @regexp_backref +| 23 = @regexp_char_class +| 24 = @regexp_char_range +| 25 = @regexp_positive_lookbehind +| 26 = @regexp_negative_lookbehind +| 27 = @regexp_unicode_property_escape; + +regexp_parse_errors (unique int id: @regexp_parse_error, + int regexp: @regexpterm ref, + varchar(900) message: string ref); + +@regexp_quantifier = @regexp_star | @regexp_plus | @regexp_opt | @regexp_range; +@regexp_escape = @regexp_char_escape | @regexp_char_class_escape | @regexp_unicode_property_escape; +@regexp_char_escape = @regexp_hex_escape | @regexp_unicode_escape | @regexp_dec_escape | @regexp_oct_escape | @regexp_ctrl_escape | @regexp_id_escape; +@regexp_constant = @regexp_normal_constant | @regexp_char_escape; +@regexp_lookahead = @regexp_positive_lookahead | @regexp_negative_lookahead; +@regexp_lookbehind = @regexp_positive_lookbehind | @regexp_negative_lookbehind; +@regexp_subpattern = @regexp_lookahead | @regexp_lookbehind; +@regexp_anchor = @regexp_dollar | @regexp_caret; + +is_greedy (int id: @regexp_quantifier ref); +range_quantifier_lower_bound (unique int id: @regexp_range ref, int lo: int ref); +range_quantifier_upper_bound (unique int id: @regexp_range ref, int hi: int ref); +is_capture (unique int id: @regexp_group ref, int number: int ref); +is_named_capture (unique int id: @regexp_group ref, string name: string ref); +is_inverted (int id: @regexp_char_class ref); +regexp_const_value (unique int id: @regexp_constant ref, varchar(1) value: string ref); +char_class_escape (unique int id: @regexp_char_class_escape ref, varchar(1) value: string ref); +backref (unique int id: @regexp_backref ref, int value: int ref); +named_backref (unique int id: @regexp_backref ref, string name: string ref); +unicode_property_escapename (unique int id: @regexp_unicode_property_escape ref, string name: string ref); +unicode_property_escapevalue (unique int id: @regexp_unicode_property_escape ref, string value: string ref); + +// tokens +#keyset[toplevel, idx] +tokeninfo (unique int id: @token, + int kind: int ref, + int toplevel: @toplevel ref, + int idx: int ref, + varchar(900) value: string ref); + +case @token.kind of + 0 = @token_eof +| 1 = @token_null_literal +| 2 = @token_boolean_literal +| 3 = @token_numeric_literal +| 4 = @token_string_literal +| 5 = @token_regular_expression +| 6 = @token_identifier +| 7 = @token_keyword +| 8 = @token_punctuator; + +// associate comments with the token immediately following them (which may be EOF) +next_token (int comment: @comment ref, int token: @token ref); + +// JSON +#keyset[parent, idx] +json (unique int id: @json_value, + int kind: int ref, + int parent: @json_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +json_literals (varchar(900) value: string ref, + varchar(900) raw: string ref, + unique int expr: @json_value ref); + +json_properties (int obj: @json_object ref, + varchar(900) property: string ref, + int value: @json_value ref); + +json_errors (unique int id: @json_parse_error, + varchar(900) message: string ref); + +json_locations(unique int locatable: @json_locatable ref, + int location: @location_default ref); + +case @json_value.kind of + 0 = @json_null +| 1 = @json_boolean +| 2 = @json_number +| 3 = @json_string +| 4 = @json_array +| 5 = @json_object; + +@json_parent = @json_object | @json_array | @file; + +@json_locatable = @json_value | @json_parse_error; + +// locations +@ast_node = @toplevel | @stmt | @expr | @property | @typeexpr; + +@locatable = @file + | @ast_node + | @comment + | @line + | @js_parse_error | @regexp_parse_error + | @regexpterm + | @json_locatable + | @token + | @cfg_node + | @jsdoc | @jsdoc_type_expr | @jsdoc_tag + | @yaml_locatable + | @xmllocatable + | @configLocatable + | @template_placeholder_tag; + +hasLocation (unique int locatable: @locatable ref, + int location: @location ref); + +// CFG +entry_cfg_node (unique int id: @entry_node, int container: @stmt_container ref); +exit_cfg_node (unique int id: @exit_node, int container: @stmt_container ref); +guard_node (unique int id: @guard_node, int kind: int ref, int test: @expr ref); +case @guard_node.kind of + 0 = @falsy_guard +| 1 = @truthy_guard; +@condition_guard = @falsy_guard | @truthy_guard; + +@synthetic_cfg_node = @entry_node | @exit_node | @guard_node; +@cfg_node = @synthetic_cfg_node | @expr_parent; + +successor (int pred: @cfg_node ref, int succ: @cfg_node ref); + +// JSDoc comments +jsdoc (unique int id: @jsdoc, varchar(900) description: string ref, int comment: @comment ref); +#keyset[parent, idx] +jsdoc_tags (unique int id: @jsdoc_tag, varchar(900) title: string ref, + int parent: @jsdoc ref, int idx: int ref, varchar(900) tostring: string ref); +jsdoc_tag_descriptions (unique int tag: @jsdoc_tag ref, varchar(900) text: string ref); +jsdoc_tag_names (unique int tag: @jsdoc_tag ref, varchar(900) text: string ref); + +#keyset[parent, idx] +jsdoc_type_exprs (unique int id: @jsdoc_type_expr, + int kind: int ref, + int parent: @jsdoc_type_expr_parent ref, + int idx: int ref, + varchar(900) tostring: string ref); +case @jsdoc_type_expr.kind of + 0 = @jsdoc_any_type_expr +| 1 = @jsdoc_null_type_expr +| 2 = @jsdoc_undefined_type_expr +| 3 = @jsdoc_unknown_type_expr +| 4 = @jsdoc_void_type_expr +| 5 = @jsdoc_named_type_expr +| 6 = @jsdoc_applied_type_expr +| 7 = @jsdoc_nullable_type_expr +| 8 = @jsdoc_non_nullable_type_expr +| 9 = @jsdoc_record_type_expr +| 10 = @jsdoc_array_type_expr +| 11 = @jsdoc_union_type_expr +| 12 = @jsdoc_function_type_expr +| 13 = @jsdoc_optional_type_expr +| 14 = @jsdoc_rest_type_expr +; + +#keyset[id, idx] +jsdoc_record_field_name (int id: @jsdoc_record_type_expr ref, int idx: int ref, varchar(900) name: string ref); +jsdoc_prefix_qualifier (int id: @jsdoc_type_expr ref); +jsdoc_has_new_parameter (int fn: @jsdoc_function_type_expr ref); + +@jsdoc_type_expr_parent = @jsdoc_type_expr | @jsdoc_tag; + +jsdoc_errors (unique int id: @jsdoc_error, int tag: @jsdoc_tag ref, varchar(900) message: string ref, varchar(900) tostring: string ref); + +// YAML +#keyset[parent, idx] +yaml (unique int id: @yaml_node, + int kind: int ref, + int parent: @yaml_node_parent ref, + int idx: int ref, + varchar(900) tag: string ref, + varchar(900) tostring: string ref); + +case @yaml_node.kind of + 0 = @yaml_scalar_node +| 1 = @yaml_mapping_node +| 2 = @yaml_sequence_node +| 3 = @yaml_alias_node +; + +@yaml_collection_node = @yaml_mapping_node | @yaml_sequence_node; + +@yaml_node_parent = @yaml_collection_node | @file; + +yaml_anchors (unique int node: @yaml_node ref, + varchar(900) anchor: string ref); + +yaml_aliases (unique int alias: @yaml_alias_node ref, + varchar(900) target: string ref); + +yaml_scalars (unique int scalar: @yaml_scalar_node ref, + int style: int ref, + varchar(900) value: string ref); + +yaml_errors (unique int id: @yaml_error, + varchar(900) message: string ref); + +yaml_locations(unique int locatable: @yaml_locatable ref, + int location: @location_default ref); + +@yaml_locatable = @yaml_node | @yaml_error; + +/* XML Files */ + +xmlEncoding( + unique int id: @file ref, + varchar(900) encoding: string ref +); + +xmlDTDs( + unique int id: @xmldtd, + varchar(900) root: string ref, + varchar(900) publicId: string ref, + varchar(900) systemId: string ref, + int fileid: @file ref +); + +xmlElements( + unique int id: @xmlelement, + varchar(900) name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref +); + +xmlAttrs( + unique int id: @xmlattribute, + int elementid: @xmlelement ref, + varchar(900) name: string ref, + varchar(3600) value: string ref, + int idx: int ref, + int fileid: @file ref +); + +xmlNs( + int id: @xmlnamespace, + varchar(900) prefixName: string ref, + varchar(900) URI: string ref, + int fileid: @file ref +); + +xmlHasNs( + int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref +); + +xmlComments( + unique int id: @xmlcomment, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref +); + +xmlChars( + unique int id: @xmlcharacters, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref +); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations( + int xmlElement: @xmllocatable ref, + int location: @location_default ref +); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; + +@dataflownode = @expr | @function_decl_stmt | @class_decl_stmt | @namespace_declaration | @enum_declaration | @property; + +@optionalchainable = @call_expr | @propaccess; + +isOptionalChaining(int id: @optionalchainable ref); + +/* + * configuration files with key value pairs + */ + +configs( + unique int id: @config +); + +configNames( + unique int id: @configName, + int config: @config ref, + string name: string ref +); + +configValues( + unique int id: @configValue, + int config: @config ref, + string value: string ref +); + +configLocations( + int locatable: @configLocatable ref, + int location: @location_default ref +); + +@configLocatable = @config | @configName | @configValue; + +/** + * The time taken for the extraction of a file. + * This table contains non-deterministic content. + * + * The sum of the `time` column for each (`file`, `timerKind`) pair + * is the total time taken for extraction of `file`. The `extractionPhase` + * column provides a granular view of the extraction time of the file. + */ +extraction_time( + int file : @file ref, + // see `com.semmle.js.extractor.ExtractionMetrics.ExtractionPhase`. + int extractionPhase: int ref, + // 0 for the elapsed CPU time in nanoseconds, 1 for the elapsed wallclock time in nanoseconds + int timerKind: int ref, + float time: float ref +) + +/** + * Non-timing related data for the extraction of a single file. + * This table contains non-deterministic content. + */ +extraction_data( + int file : @file ref, + // the absolute path to the cache file + varchar(900) cacheFile: string ref, + boolean fromCache: boolean ref, + int length: int ref +) diff --git a/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/upgrade.properties b/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/upgrade.properties new file mode 100644 index 00000000000..7ece91dec13 --- /dev/null +++ b/javascript/upgrades/8320e9d13aad4f77a4348e744b55024e785bfcdf/upgrade.properties @@ -0,0 +1,2 @@ +description: 'add @import_specifier to @import_or_export_declaration, and rename @import_or_export_declaration to @type_keyword_operand' +compatibility: backwards