Skip to content

Commit 302199a

Browse files
committed
fix TypeExprKinds crashing on a ThisExpression
1 parent abef848 commit 302199a

File tree

4 files changed

+171
-118
lines changed

4 files changed

+171
-118
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.semmle.js.ast.Literal;
88
import com.semmle.js.ast.MemberExpression;
99
import com.semmle.js.ast.TemplateElement;
10+
import com.semmle.js.ast.ThisExpression;
1011
import com.semmle.js.extractor.ASTExtractor.IdContext;
1112
import com.semmle.ts.ast.ArrayTypeExpr;
1213
import com.semmle.ts.ast.ConditionalTypeExpr;
@@ -100,6 +101,11 @@ public Integer visit(KeywordTypeExpr nd, Void c) {
100101
return keywordTypeExpr;
101102
}
102103

104+
@Override
105+
public Integer visit(ThisExpression nd, Void c) {
106+
return thisVarTypeAccess;
107+
}
108+
103109
@Override
104110
public Integer visit(ArrayTypeExpr nd, Void c) {
105111
return arrayTypeExpr;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Test case taken from babel: https://github.com/babel/babel/blob/main/packages/babel-parser/test/fixtures/typescript/regression/keyword-qualified-type-2/input.ts
2+
3+
// These are valid TypeScript syntax (the parser doesn't produce any error),
4+
// but they are always type-checking errors.
5+
interface A extends this.B {}
6+
type T = typeof var.bar;

0 commit comments

Comments
 (0)