mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
TypeScript: support syntax for optional tuple type elements
This commit is contained in:
@@ -1073,6 +1073,14 @@ class IsTypeExpr extends @istypeexpr, TypeExpr {
|
||||
TypeExpr getPredicateType() { result = this.getChildTypeExpr(1) }
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional type element in a tuple type, such as `number?` in `[string, number?]`.
|
||||
*/
|
||||
class OptionalTypeExpr extends @optionaltypeexpr, TypeExpr {
|
||||
/** Gets the type `T` in `T?` */
|
||||
TypeExpr getElementType() { result = getChildTypeExpr(0) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A possibly qualified name that refers to a variable from inside a type.
|
||||
*
|
||||
|
||||
@@ -556,7 +556,9 @@ case @typeexpr.kind of
|
||||
| 29 = @infertypeexpr
|
||||
| 30 = @importtypeaccess
|
||||
| 31 = @importnamespaceaccess
|
||||
| 32 = @importvartypeaccess;
|
||||
| 32 = @importvartypeaccess
|
||||
| 33 = @optionaltypeexpr
|
||||
;
|
||||
|
||||
@typeref = @typeaccess | @typedecl;
|
||||
@typeidentifier = @typedecl | @localtypeaccess | @typelabel | @localvartypeaccess | @localnamespaceaccess;
|
||||
|
||||
@@ -3,3 +3,6 @@
|
||||
| tst.ts:48:16:48:40 | [number ... oolean] | 2 | 3 | tst.ts:48:33:48:39 | boolean |
|
||||
| tst.ts:95:31:95:35 | [S,T] | 0 | 2 | tst.ts:95:32:95:32 | S |
|
||||
| tst.ts:95:31:95:35 | [S,T] | 1 | 2 | tst.ts:95:34:95:34 | T |
|
||||
| tst.ts:133:31:133:55 | [number ... umber?] | 0 | 3 | tst.ts:133:32:133:37 | number |
|
||||
| tst.ts:133:31:133:55 | [number ... umber?] | 1 | 3 | tst.ts:133:40:133:45 | string |
|
||||
| tst.ts:133:31:133:55 | [number ... umber?] | 2 | 3 | tst.ts:133:48:133:54 | number? |
|
||||
|
||||
@@ -69,3 +69,5 @@
|
||||
| tst.ts:126:5:126:18 | importedTypeof | importedTypeof | tst.ts:126:21:126:42 | typeof ... value") |
|
||||
| tst.ts:127:5:127:27 | importe ... dTypeof | importedQualifiedTypeof | tst.ts:127:30:127:53 | typeof ... lue").x |
|
||||
| tst.ts:128:5:128:35 | importe ... tespace | importedQualifiedTypeWhitespace | tst.ts:131:4:131:6 | bar |
|
||||
| tst.ts:133:5:133:28 | tupleWi ... Element | tupleWithOptionalElement | tst.ts:133:31:133:55 | [number ... umber?] |
|
||||
| tst.ts:134:5:134:14 | emptyTuple | emptyTuple | tst.ts:134:17:134:18 | [] |
|
||||
|
||||
@@ -129,3 +129,6 @@ var importedQualifiedTypeWhitespace: import(
|
||||
'awkard-namespace'
|
||||
)
|
||||
.bar;
|
||||
|
||||
let tupleWithOptionalElement: [number, string, number?];
|
||||
let emptyTuple: [];
|
||||
|
||||
Reference in New Issue
Block a user