mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
aggregate the tests in library-tests/TypeScript/TypeVariableTypes into a single .ql file
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
| T | GenericMethods.T in global scope |
|
||||
| T | Repeated.T in global scope |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from CanonicalTypeVariableType type
|
||||
select type, type.getCanonicalName()
|
||||
@@ -1,3 +0,0 @@
|
||||
| D | D |
|
||||
| E | E |
|
||||
| S | S |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from LexicalTypeVariableType type
|
||||
select type, type.getName()
|
||||
@@ -1,7 +0,0 @@
|
||||
| <D>(x: D): D | 1 | 0 | D | no bound |
|
||||
| <E>(x: () => E): E | 1 | 0 | E | no bound |
|
||||
| <E>(x: E[] \| (() => E)): E | 1 | 0 | E | no bound |
|
||||
| <E>(x: E[]): E | 1 | 0 | E | no bound |
|
||||
| <S extends any[]>(x: S, y: T[]): S | 1 | 0 | S | any[] |
|
||||
| <S>(x: S, y: S): S | 1 | 0 | S | no bound |
|
||||
| <S>(x: S, y: T): [S, T] | 1 | 0 | S | no bound |
|
||||
@@ -1,12 +0,0 @@
|
||||
import javascript
|
||||
|
||||
string getBound(CallSignatureType sig, int n) {
|
||||
result = sig.getTypeParameterBound(n).toString()
|
||||
or
|
||||
not exists(sig.getTypeParameterBound(n)) and
|
||||
result = "no bound" and
|
||||
n = [0 .. sig.getNumTypeParameter() - 1]
|
||||
}
|
||||
|
||||
from CallSignatureType sig, int n
|
||||
select sig, sig.getNumTypeParameter(), n, sig.getTypeParameterName(n), getBound(sig, n)
|
||||
@@ -1,2 +0,0 @@
|
||||
| Apple.this | Apple |
|
||||
| Banana.this | Banana |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from ThisType type
|
||||
select type, type.getEnclosingType()
|
||||
@@ -1,2 +0,0 @@
|
||||
| T | GenericMethods.T in global scope |
|
||||
| T | Repeated.T in global scope |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from TypeVariableType type
|
||||
select type, type.getCanonicalName()
|
||||
@@ -1,3 +0,0 @@
|
||||
| T | GenericMethods.T in global scope | tst.ts:22:26:22:26 | T |
|
||||
| T | Repeated.T in global scope | tst.ts:3:20:3:20 | T |
|
||||
| T | Repeated.T in global scope | tst.ts:7:20:7:20 | T |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from TypeVariableType tv
|
||||
select tv, tv.getCanonicalName(), tv.getADeclaration()
|
||||
@@ -1,2 +0,0 @@
|
||||
| T | GenericMethods.T in global scope | GenericMethods in global scope |
|
||||
| T | Repeated.T in global scope | Repeated in global scope |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from TypeVariableType type
|
||||
select type, type.getCanonicalName(), type.getHostType()
|
||||
@@ -0,0 +1,28 @@
|
||||
canonicalTypeVariableType
|
||||
| T | GenericMethods.T in global scope |
|
||||
| T | Repeated.T in global scope |
|
||||
lexicalTypeVariableType
|
||||
| D | D |
|
||||
| E | E |
|
||||
| S | S |
|
||||
signatureTypeParameters
|
||||
| <D>(x: D): D | 0 | 1 | D | no bound |
|
||||
| <E>(x: () => E): E | 0 | 1 | E | no bound |
|
||||
| <E>(x: E[] \| (() => E)): E | 0 | 1 | E | no bound |
|
||||
| <E>(x: E[]): E | 0 | 1 | E | no bound |
|
||||
| <S extends any[]>(x: S, y: T[]): S | 0 | 1 | S | any[] |
|
||||
| <S>(x: S, y: S): S | 0 | 1 | S | no bound |
|
||||
| <S>(x: S, y: T): [S, T] | 0 | 1 | S | no bound |
|
||||
thisType
|
||||
| Apple.this | Apple |
|
||||
| Banana.this | Banana |
|
||||
typeVariableCanonicalNames
|
||||
| T | GenericMethods.T in global scope |
|
||||
| T | Repeated.T in global scope |
|
||||
typeVariableDecl
|
||||
| T | GenericMethods.T in global scope | tst.ts:22:26:22:26 | T |
|
||||
| T | Repeated.T in global scope | tst.ts:3:20:3:20 | T |
|
||||
| T | Repeated.T in global scope | tst.ts:7:20:7:20 | T |
|
||||
typeVariableHost
|
||||
| T | GenericMethods.T in global scope | GenericMethods in global scope |
|
||||
| T | Repeated.T in global scope | Repeated in global scope |
|
||||
@@ -0,0 +1,43 @@
|
||||
import javascript
|
||||
|
||||
query predicate canonicalTypeVariableType(CanonicalTypeVariableType type, CanonicalName name) {
|
||||
type.getCanonicalName() = name
|
||||
}
|
||||
|
||||
query predicate lexicalTypeVariableType(LexicalTypeVariableType type, string name) {
|
||||
type.getName() = name
|
||||
}
|
||||
|
||||
string getBound(CallSignatureType sig, int n) {
|
||||
result = sig.getTypeParameterBound(n).toString()
|
||||
or
|
||||
not exists(sig.getTypeParameterBound(n)) and
|
||||
result = "no bound" and
|
||||
n = [0 .. sig.getNumTypeParameter() - 1]
|
||||
}
|
||||
|
||||
query predicate signatureTypeParameters(
|
||||
CallSignatureType sig, int n, int numTypeParam, string paramName, string bound
|
||||
) {
|
||||
sig.getNumTypeParameter() = numTypeParam and
|
||||
sig.getTypeParameterName(n) = paramName and
|
||||
bound = getBound(sig, n)
|
||||
}
|
||||
|
||||
query predicate thisType(ThisType type, TypeReference enclosing) {
|
||||
type.getEnclosingType() = enclosing
|
||||
}
|
||||
|
||||
query predicate typeVariableCanonicalNames(TypeVariableType type, CanonicalName name) {
|
||||
type.getCanonicalName() = name
|
||||
}
|
||||
|
||||
query predicate typeVariableDecl(TypeVariableType tv, CanonicalName name, TypeParameter decl) {
|
||||
tv.getCanonicalName() = name and
|
||||
tv.getADeclaration() = decl
|
||||
}
|
||||
|
||||
query predicate typeVariableHost(TypeVariableType type, CanonicalName name, TypeName hostType) {
|
||||
type.getCanonicalName() = name and
|
||||
type.getHostType() = hostType
|
||||
}
|
||||
Reference in New Issue
Block a user