mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
TypeScript: support syntax for unknown types
This commit is contained in:
@@ -686,6 +686,9 @@ class TypeExpr extends ExprOrType, @typeexpr {
|
|||||||
/** Holds if this is the `object` type. */
|
/** Holds if this is the `object` type. */
|
||||||
predicate isObjectKeyword() { none() }
|
predicate isObjectKeyword() { none() }
|
||||||
|
|
||||||
|
/** Holds if this is the `unknown` type. */
|
||||||
|
predicate isUnknownKeyword() { none() }
|
||||||
|
|
||||||
/** Gets this type expression, with any surrounding parentheses removed. */
|
/** Gets this type expression, with any surrounding parentheses removed. */
|
||||||
override TypeExpr stripParens() {
|
override TypeExpr stripParens() {
|
||||||
result = this
|
result = this
|
||||||
@@ -725,6 +728,7 @@ private class KeywordTypeExpr extends @keywordtypeexpr, TypeExpr {
|
|||||||
override predicate isSymbol() { getName() = "symbol" }
|
override predicate isSymbol() { getName() = "symbol" }
|
||||||
override predicate isUniqueSymbol() { getName() = "unique symbol" }
|
override predicate isUniqueSymbol() { getName() = "unique symbol" }
|
||||||
override predicate isObjectKeyword() { getName() = "object" }
|
override predicate isObjectKeyword() { getName() = "object" }
|
||||||
|
override predicate isUnknownKeyword() { getName() = "unknown" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
| tst.ts:137:18:137:24 | unknown |
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import javascript
|
||||||
|
|
||||||
|
from TypeExpr type
|
||||||
|
where type.isUnknownKeyword()
|
||||||
|
select type
|
||||||
@@ -134,3 +134,4 @@ let tupleWithOptionalElement: [number, string, number?];
|
|||||||
let emptyTuple: [];
|
let emptyTuple: [];
|
||||||
let tupleWithRestElement: [number, ...string[]];
|
let tupleWithRestElement: [number, ...string[]];
|
||||||
let tupleWithOptionalAndRestElements: [number, string?, ...number[]];
|
let tupleWithOptionalAndRestElements: [number, string?, ...number[]];
|
||||||
|
let unknownType: unknown;
|
||||||
|
|||||||
Reference in New Issue
Block a user