Skip to content

Commit b228398

Browse files
authored
Merge pull request github#6587 from erik-krogh/ts44
Approved by asgerf
2 parents 0e7afb2 + cf149bd commit b228398

31 files changed

+3532
-67
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Eclipse compiler for Java (ECJ) [5]_",``.java``
2323
JavaScript,ECMAScript 2021 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhm``, ``.xhtml``, ``.vue``, ``.json``, ``.yaml``, ``.yml``, ``.raml``, ``.xml`` [6]_"
2424
Python,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9",Not applicable,``.py``
25-
TypeScript [7]_,"2.6-4.2",Standard TypeScript compiler,"``.ts``, ``.tsx``"
25+
TypeScript [7]_,"2.6-4.4",Standard TypeScript compiler,"``.ts``, ``.tsx``"
2626

2727
.. container:: footnote-group
2828

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* TypeScript 4.4 is now supported.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* Support for the ECMAScript proposed feature "class static initialization blocks" has been added.

javascript/extractor/lib/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript-parser-wrapper",
33
"private": true,
44
"dependencies": {
5-
"typescript": "4.3.5"
5+
"typescript": "4.4.2"
66
},
77
"scripts": {
88
"build": "tsc --project tsconfig.json",

javascript/extractor/lib/typescript/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
version "12.7.11"
77
resolved node-12.7.11.tgz#be879b52031cfb5d295b047f5462d8ef1a716446
88

9-
typescript@4.3.5:
10-
version "4.3.5"
11-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
12-
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
9+
typescript@4.4.2:
10+
version "4.4.2"
11+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
12+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==

javascript/extractor/src/com/semmle/jcorn/Parser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import com.semmle.js.ast.SourceLocation;
8484
import com.semmle.js.ast.SpreadElement;
8585
import com.semmle.js.ast.Statement;
86+
import com.semmle.js.ast.StaticInitializer;
8687
import com.semmle.js.ast.Super;
8788
import com.semmle.js.ast.SwitchCase;
8889
import com.semmle.js.ast.SwitchStatement;
@@ -3244,6 +3245,10 @@ protected MemberDefinition<?> parseClassMember(boolean hadConstructor) {
32443245
PropertyInfo pi = new PropertyInfo(false, isGenerator, methodStartLoc);
32453246
this.parsePropertyName(pi);
32463247
boolean isStatic = isMaybeStatic && this.type != TokenType.parenL;
3248+
if (isStatic && this.type == TokenType.braceL) {
3249+
BlockStatement block = parseBlock(false);
3250+
return new StaticInitializer(block.getLoc(), block);
3251+
}
32473252
if (isStatic) {
32483253
if (isGenerator) this.unexpected();
32493254
isGenerator = this.eat(TokenType.star);

javascript/extractor/src/com/semmle/js/ast/DefaultVisitor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,4 +782,9 @@ public R visit(XMLDotDotExpression nd, C c) {
782782
public R visit(GeneratedCodeExpr nd, C c) {
783783
return visit((Expression) nd, c);
784784
}
785+
786+
@Override
787+
public R visit(StaticInitializer nd, C c) {
788+
return visit((MemberDefinition<BlockStatement>) nd, c);
789+
}
785790
}

javascript/extractor/src/com/semmle/js/ast/MemberDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* <p>A member definition has a name and an optional initial value, whose type is given by the type
1010
* parameter {@code V}.
1111
*/
12-
public abstract class MemberDefinition<V extends Expression> extends Node {
12+
public abstract class MemberDefinition<V extends Node> extends Node {
1313
/** A bitmask of flags defined in {@linkplain DeclarationFlags}. */
1414
private final int flags;
1515

@@ -21,7 +21,7 @@ public abstract class MemberDefinition<V extends Expression> extends Node {
2121
*/
2222
private final Expression key;
2323

24-
/** The initial value of the member. */
24+
/** The initial value / initializer of the member. */
2525
private final V value;
2626

2727
/** The decorators applied to this member, if any. */

javascript/extractor/src/com/semmle/js/ast/NodeCopier.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,11 @@ public INode visit(XMLDotDotExpression nd, Void c) {
897897

898898
@Override
899899
public INode visit(GeneratedCodeExpr nd, Void c) {
900-
return new GeneratedCodeExpr(visit(nd.getLoc()), nd.getOpeningDelimiter(), nd.getClosingDelimiter(), nd.getBody());
900+
return new GeneratedCodeExpr(visit(nd.getLoc()), nd.getOpeningDelimiter(), nd.getClosingDelimiter(), nd.getBody());
901+
}
902+
903+
@Override
904+
public INode visit(StaticInitializer nd, Void c) {
905+
return new StaticInitializer(visit(nd.getLoc()), copy(nd.getValue()));
901906
}
902907
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.semmle.js.ast;
2+
3+
/**
4+
* A static initializer block in a class. E.g. ```TypeScript class Foo { static
5+
* bar : number; static { Foo.bar = 42; } }
6+
*/
7+
public class StaticInitializer extends MemberDefinition<BlockStatement> {
8+
public StaticInitializer(SourceLocation loc, BlockStatement body) {
9+
super("StaticInitializer", loc, DeclarationFlags.static_, null, body);
10+
}
11+
12+
@Override
13+
public boolean isConcrete() {
14+
return false;
15+
}
16+
17+
@Override
18+
public <C, R> R accept(Visitor<C, R> v, C c) {
19+
return v.visit(this, c);
20+
}
21+
}

0 commit comments

Comments
 (0)