Merge remote-tracking branch 'upstream/master' into promiseAll

This commit is contained in:
Erik Krogh Kristensen
2019-11-25 14:34:58 +01:00
179 changed files with 4849 additions and 1150 deletions

View File

@@ -47,14 +47,39 @@ test_ExprSignature
| tst.ts:45:15:45:15 | x | string |
| tst.ts:46:3:46:25 | constru ... umber); | any |
| tst.ts:46:15:46:15 | x | number |
| tst.ts:50:3:50:36 | method( ... ing[]); | (x: number, ...y: string[]): any |
| tst.ts:50:10:50:10 | x | number |
| tst.ts:50:24:50:24 | y | string[] |
| tst.ts:51:4:51:4 | x | number |
| tst.ts:51:18:51:18 | y | string[] |
| tst.ts:52:7:52:7 | x | number |
| tst.ts:52:21:52:21 | y | string[] |
| tst.ts:54:3:54:34 | method2 ... ing[]); | (x: number, y: string[]): any |
| tst.ts:54:11:54:11 | x | number |
| tst.ts:54:22:54:22 | y | string[] |
| tst.ts:55:3:55:32 | method3 ... tring); | (x: number, y: string): any |
| tst.ts:55:11:55:11 | x | number |
| tst.ts:55:22:55:22 | y | string |
| tst.ts:59:3:59:25 | method( ... ing[]); | (...y: string[]): any |
| tst.ts:59:13:59:13 | y | string[] |
| tst.ts:60:7:60:7 | y | string[] |
| tst.ts:61:10:61:10 | y | string[] |
| tst.ts:63:3:63:23 | method2 ... ing[]); | (y: string[]): any |
| tst.ts:63:11:63:11 | y | string[] |
| tst.ts:64:3:64:21 | method3(y: string); | (y: string): any |
| tst.ts:64:11:64:11 | y | string |
test_TypeReferenceSig
| Callable | function | 0 | (x: number): string |
| Newable | constructor | 0 | new (x: number): any |
| OnlyRestParams | constructor | 0 | new (...y: string[]): any |
| OnlyRestParams | function | 0 | (...y: string[]): any |
| OverloadedCallable | function | 0 | (x: number): number |
| OverloadedCallable | function | 1 | (x: string): string |
| OverloadedCallable | function | 2 | (x: any): any |
| OverloadedNewable | constructor | 0 | new (x: number): OverloadedNewable |
| OverloadedNewable | constructor | 1 | new (x: any): any |
| WithRestParams | constructor | 0 | new (x: number, ...y: string[]): any |
| WithRestParams | function | 0 | (x: number, ...y: string[]): any |
test_FunctionCallSig
| tst.ts:2:3:2:22 | (x: number): string; | (x: number): string |
| tst.ts:6:3:6:22 | (x: number): number; | (x: number): number |
@@ -72,3 +97,62 @@ test_FunctionCallSig
| tst.ts:40:1:42:1 | functio ... oo");\\n} | (g: Generic<string>): string |
| tst.ts:45:3:45:25 | constru ... tring); | new (x: string): C |
| tst.ts:46:3:46:25 | constru ... umber); | new (x: number): C |
| tst.ts:50:3:50:36 | method( ... ing[]); | (x: number, ...y: string[]): any |
| tst.ts:51:3:51:30 | (x: num ... ing[]); | (x: number, ...y: string[]): any |
| tst.ts:52:3:52:33 | new(x: ... ing[]); | new (x: number, ...y: string[]): any |
| tst.ts:54:3:54:34 | method2 ... ing[]); | (x: number, y: string[]): any |
| tst.ts:55:3:55:32 | method3 ... tring); | (x: number, y: string): any |
| tst.ts:59:3:59:25 | method( ... ing[]); | (...y: string[]): any |
| tst.ts:60:3:60:19 | (...y: string[]); | (...y: string[]): any |
| tst.ts:61:3:61:22 | new(...y: string[]); | new (...y: string[]): any |
| tst.ts:63:3:63:23 | method2 ... ing[]); | (y: string[]): any |
| tst.ts:64:3:64:21 | method3(y: string); | (y: string): any |
test_getRestParameterType
| (...items: (string \| ConcatArray<string>)[]): string[] | string \| ConcatArray<string> |
| (...items: ConcatArray<string>[]): string[] | ConcatArray<string> |
| (...items: string[]): number | string |
| (...strings: string[]): string | string |
| (...y: string[]): any | string |
| (start: number, deleteCount: number, ...items: string[]): string[] | string |
| (substring: string, ...args: any[]): string | any |
| (x: number, ...y: string[]): any | string |
| new (...y: string[]): any | string |
| new (x: number, ...y: string[]): any | string |
test_getRestParameterArray
| (...items: (string \| ConcatArray<string>)[]): string[] | (string \| ConcatArray<string>)[] |
| (...items: ConcatArray<string>[]): string[] | ConcatArray<string>[] |
| (...items: string[]): number | string[] |
| (...strings: string[]): string | string[] |
| (...y: string[]): any | string[] |
| (start: number, deleteCount: number, ...items: string[]): string[] | string[] |
| (substring: string, ...args: any[]): string | any[] |
| (x: number, ...y: string[]): any | string[] |
| new (...y: string[]): any | string[] |
| new (x: number, ...y: string[]): any | string[] |
test_RestSig_getParameter
| (...items: (string \| ConcatArray<string>)[]): string[] | 0 | items | string \| ConcatArray<string> |
| (...items: ConcatArray<string>[]): string[] | 0 | items | ConcatArray<string> |
| (...items: string[]): number | 0 | items | string |
| (...strings: string[]): string | 0 | strings | string |
| (...y: string[]): any | 0 | y | string |
| (start: number, deleteCount: number, ...items: string[]): string[] | 0 | start | number |
| (start: number, deleteCount: number, ...items: string[]): string[] | 1 | deleteCount | number |
| (start: number, deleteCount: number, ...items: string[]): string[] | 2 | items | string |
| (substring: string, ...args: any[]): string | 0 | substring | string |
| (substring: string, ...args: any[]): string | 1 | args | any |
| (x: number, ...y: string[]): any | 0 | x | number |
| (x: number, ...y: string[]): any | 1 | y | string |
| new (...y: string[]): any | 0 | y | string |
| new (x: number, ...y: string[]): any | 0 | x | number |
| new (x: number, ...y: string[]): any | 1 | y | string |
test_RestSig_numRequiredParams
| (...items: (string \| ConcatArray<string>)[]): string[] | 0 |
| (...items: ConcatArray<string>[]): string[] | 0 |
| (...items: string[]): number | 0 |
| (...strings: string[]): string | 0 |
| (...y: string[]): any | 0 |
| (start: number, deleteCount: number, ...items: string[]): string[] | 2 |
| (substring: string, ...args: any[]): string | 1 |
| (x: number, ...y: string[]): any | 1 |
| new (...y: string[]): any | 0 |
| new (x: number, ...y: string[]): any | 1 |

View File

@@ -20,3 +20,22 @@ query predicate test_TypeReferenceSig(TypeReference type, SignatureKind kind, in
query predicate test_FunctionCallSig(Function f, CallSignatureType sig) {
sig = f.getCallSignature()
}
query Type test_getRestParameterType(CallSignatureType sig) {
result = sig.getRestParameterType()
}
query Type test_getRestParameterArray(CallSignatureType sig) {
result = sig.getRestParameterArrayType()
}
query predicate test_RestSig_getParameter(CallSignatureType sig, int n, string name, Type type) {
sig.hasRestParameter() and
name = sig.getParameterName(n) and
type = sig.getParameter(n)
}
query int test_RestSig_numRequiredParams(CallSignatureType sig) {
sig.hasRestParameter() and
result = sig.getNumRequiredParameter()
}

View File

@@ -45,3 +45,21 @@ declare class C {
constructor(x: string);
constructor(x: number);
}
interface WithRestParams {
method(x: number, ...y: string[]);
(x: number, ...y: string[]);
new(x: number, ...y: string[]);
method2(x: number, y: string[]);
method3(x: number, y: string);
}
interface OnlyRestParams {
method(...y: string[]);
(...y: string[]);
new(...y: string[]);
method2(y: string[]);
method3(y: string);
}

View File

@@ -0,0 +1,9 @@
exprType
| tst.ts:1:5:1:16 | stringOrNUll | string \| null |
| tst.ts:2:5:2:21 | stringOrUndefined | string \| undefined |
| tst.ts:3:5:3:27 | stringO ... defined | string \| null \| undefined |
| tst.ts:4:5:4:16 | stringOrVoid | string \| void |
| tst.ts:7:5:7:21 | stringOrNullAlias | string \| null |
| tst.ts:8:5:8:32 | stringO ... defined | string \| null \| undefined |
| tst.ts:10:5:10:23 | arrayOfStringOrNull | (string \| null)[] |
unaliasedType

View File

@@ -0,0 +1,5 @@
import javascript
query Type exprType(Expr e) { result = e.getType() }
query Type unaliasedType(TypeAliasReference ref) { result = ref.getAliasedType() }

View File

@@ -0,0 +1,6 @@
{
"include": ["."],
"compilerOptions": {
"strict": true
}
}

View File

@@ -0,0 +1,10 @@
let stringOrNUll: string | null;
let stringOrUndefined: string | undefined;
let stringOrNullOrUndefined: string | null | undefined;
let stringOrVoid: string | void;
type StringOrNullAlias = string | null;
let stringOrNullAlias: StringOrNullAlias;
let stringOrNullAliasOrUndefined: StringOrNullAlias | undefined;
let arrayOfStringOrNull: Array<string | null>;

View File

@@ -0,0 +1,15 @@
| tst.ts:1:23:1:23 | y |
| tst.ts:2:16:2:16 | y |
| tst.ts:6:28:6:28 | y |
| tst.ts:8:12:8:12 | x |
| tst.ts:8:24:8:24 | y |
| tst.ts:9:13:9:13 | x |
| tst.ts:13:7:13:7 | x |
| tst.ts:14:13:14:13 | x |
| tst.ts:15:17:15:17 | y |
| tst.ts:18:26:18:26 | y |
| tst.ts:18:30:18:30 | z |
| tst.ts:18:34:18:34 | w |
| tst.ts:20:40:20:45 | {x, y} |
| tst.ts:20:49:20:51 | [w] |
| withDefault.ts:1:22:1:22 | x |

View File

@@ -0,0 +1,3 @@
import javascript
query Parameter optionalParams() { result.isDeclaredOptional() }

View File

@@ -0,0 +1,20 @@
function f(x: number, y?: string) {
return (x, y?) => {};
}
class C {
constructor(x: number, y?: string) {}
method(x?: number, y?: string) {}
noTypes(x?) {}
}
interface I {
m(x?: number);
field: (x?: number) => void;
(x: number, y?: string): void;
}
function manyDefaults(x, y?, z?, w?) {}
declare function optionalDestructuring({x, y}?, [w]?);

View File

@@ -0,0 +1 @@
function withDefault(x? = 5) {} // not valid syntax

View File

@@ -0,0 +1,2 @@
import f = require("./tst");
f("world");

View File

@@ -0,0 +1,5 @@
| main.ts:1:8:1:8 | f | (x: string) => string |
| main.ts:1:20:1:26 | "./tst" | any |
| main.ts:2:1:2:1 | f | (x: string) => string |
| main.ts:2:1:2:10 | f("world") | string |
| main.ts:2:3:2:9 | "world" | "world" |

View File

@@ -0,0 +1,4 @@
import javascript
from Expr e
select e, e.getType()

View File

@@ -0,0 +1,6 @@
{
"compilerOptions": {
"allowJs": true
},
"include": ["."]
}

View File

@@ -0,0 +1,6 @@
/**
* @param {String} x
*/
module.exports = function(x) {
return 'Hello ' + x;
}

View File

@@ -0,0 +1 @@
| tst.ts:0:0:0:0 | tst.ts |

View File

@@ -0,0 +1,4 @@
import javascript
from File file
select file

View File

@@ -0,0 +1,6 @@
{
"include": ["."],
"compilerOptions": {
"typeRoots": ["does-not-exist"]
}
}

View File

@@ -1,2 +0,0 @@
| test.ts:3:1:7:6 | type Di ... \\n T; | Disjunction<T> |
| test.ts:9:8:9:65 | type Tr ... n<T>>>; | Disjunction<Disjunction<Disjunction<T>>> |

View File

@@ -0,0 +1,2 @@
| tst.ts:0:0:0:0 | tst.ts |
| typeroot.d.ts:0:0:0:0 | typeroot.d.ts |

View File

@@ -0,0 +1,4 @@
import javascript
from File file
select file

View File

@@ -0,0 +1,6 @@
{
"include": ["."],
"compilerOptions": {
"typeRoots": ["typeroot.d.ts"]
}
}

View File

@@ -1,3 +1,44 @@
rightHandSide
| tst.ts:1:1:1:16 | type A = number; | number |
| tst.ts:2:1:2:16 | type B<T> = T[]; | T[] |
| tst.ts:8:10:8:20 | type C = A; | number |
| tst.ts:15:1:15:23 | type Un ... \| Two; | One \| Two |
| tst.ts:17:1:17:36 | type Un ... mber }; | (One & { x: number; }) \| (Two & { x: number; }) |
| tst.ts:18:1:18:21 | type Un ... Union2; | (One & { x: number; }) \| (Two & { x: number; }) |
| tst.ts:19:1:19:21 | type Un ... Union3; | (One & { x: number; }) \| (Two & { x: number; }) |
| tst.ts:20:1:20:30 | type Un ... number; | number \| (One & { x: number; }) \| (Two & { x: n... |
getAliasedType
| B<T> | T[] |
| B<number> | number[] |
| Union | One \| Two |
| Union2 | (One & { x: number; }) \| (Two & { x: number; }) |
| Union5 | number \| (One & { x: number; }) \| (Two & { x: n... |
getTypeArgument
| B<T> | 0 | T |
| B<number> | 0 | number |
unfold
| B<T> | B<T> |
| B<T> | T[] |
| B<number> | B<number> |
| B<number> | number[] |
| Union | One |
| Union | Two |
| Union | Union |
| Union2 | One |
| Union2 | Two |
| Union2 | Union2 |
| Union2 | { x: number; } |
| Union5 | One |
| Union5 | Two |
| Union5 | Union5 |
| Union5 | number |
| Union5 | { x: number; } |
#select
| tst.ts:1:1:1:16 | type A = number; | tst.ts:1:6:1:6 | A | 0 | tst.ts:1:10:1:15 | number |
| tst.ts:2:1:2:16 | type B<T> = T[]; | tst.ts:2:6:2:6 | B | 1 | tst.ts:2:13:2:15 | T[] |
| tst.ts:8:10:8:20 | type C = A; | tst.ts:8:15:8:15 | C | 0 | tst.ts:8:19:8:19 | A |
| tst.ts:15:1:15:23 | type Un ... \| Two; | tst.ts:15:6:15:10 | Union | 0 | tst.ts:15:14:15:22 | One \| Two |
| tst.ts:17:1:17:36 | type Un ... mber }; | tst.ts:17:6:17:11 | Union2 | 0 | tst.ts:17:15:17:35 | Union & ... umber } |
| tst.ts:18:1:18:21 | type Un ... Union2; | tst.ts:18:6:18:11 | Union3 | 0 | tst.ts:18:15:18:20 | Union2 |
| tst.ts:19:1:19:21 | type Un ... Union3; | tst.ts:19:6:19:11 | Union4 | 0 | tst.ts:19:15:19:20 | Union3 |
| tst.ts:20:1:20:30 | type Un ... number; | tst.ts:20:6:20:11 | Union5 | 0 | tst.ts:20:15:20:29 | Union4 \| number |

View File

@@ -2,3 +2,19 @@ import javascript
from TypeAliasDeclaration decl
select decl, decl.getIdentifier(), decl.getNumTypeParameter(), decl.getDefinition()
query Type rightHandSide(TypeAliasDeclaration decl) {
result = decl.getDefinition().getType()
}
query Type getAliasedType(TypeAliasReference ref) {
result = ref.getAliasedType()
}
query Type getTypeArgument(TypeAliasReference ref, int n) {
result = ref.getTypeArgument(n)
}
query Type unfold(TypeAliasReference t) {
result = t.unfold()
}

View File

@@ -0,0 +1,3 @@
{
"include": ["."]
}

View File

@@ -8,3 +8,13 @@ namespace Q {
export type C = A;
}
var z: Q.C;
interface One { a: number }
interface Two { b: number }
type Union = One | Two;
type Union2 = Union & { x: number };
type Union3 = Union2;
type Union4 = Union3;
type Union5 = Union4 | number;

View File

@@ -74,7 +74,7 @@
| type_alias.ts:5:6:5:17 | ValueOrArray | ValueOrArray<T> |
| type_alias.ts:5:19:5:19 | T | T |
| type_alias.ts:5:24:5:24 | T | T |
| type_alias.ts:5:24:5:49 | T \| Arr ... ray<T>> | ValueOrArray<T> |
| type_alias.ts:5:24:5:49 | T \| Arr ... ray<T>> | T \| ValueOrArray<T>[] |
| type_alias.ts:5:28:5:32 | Array | T[] |
| type_alias.ts:5:28:5:49 | Array<V ... ray<T>> | ValueOrArray<T>[] |
| type_alias.ts:5:34:5:45 | ValueOrArray | ValueOrArray<T> |
@@ -84,7 +84,7 @@
| type_alias.ts:7:8:7:27 | ValueOrArray<number> | ValueOrArray<number> |
| type_alias.ts:7:21:7:26 | number | number |
| type_alias.ts:9:6:9:9 | Json | Json |
| type_alias.ts:10:5:15:12 | \| strin ... Json[] | Json |
| type_alias.ts:10:5:15:12 | \| strin ... Json[] | string \| number \| boolean \| { [property: string... |
| type_alias.ts:10:7:10:12 | string | string |
| type_alias.ts:11:7:11:12 | number | number |
| type_alias.ts:12:7:12:13 | boolean | boolean |
@@ -96,7 +96,7 @@
| type_alias.ts:15:7:15:12 | Json[] | Json[] |
| type_alias.ts:17:11:17:14 | Json | Json |
| type_alias.ts:19:6:19:16 | VirtualNode | VirtualNode |
| type_alias.ts:20:5:21:56 | \| strin ... Node[]] | VirtualNode |
| type_alias.ts:20:5:21:56 | \| strin ... Node[]] | string \| [string, { [key: string]: any; }, ...V... |
| type_alias.ts:20:7:20:12 | string | string |
| type_alias.ts:21:7:21:56 | [string ... Node[]] | [string, { [key: string]: any; }, ...VirtualNod... |
| type_alias.ts:21:8:21:13 | string | string |
@@ -123,7 +123,7 @@
| type_definitions.ts:21:6:21:10 | Alias | Alias<T> |
| type_definitions.ts:21:12:21:12 | T | T |
| type_definitions.ts:21:17:21:17 | T | T |
| type_definitions.ts:21:17:21:19 | T[] | Alias<T> |
| type_definitions.ts:21:17:21:19 | T[] | T[] |
| type_definitions.ts:22:26:22:30 | Alias | Alias<T> |
| type_definitions.ts:22:26:22:38 | Alias<number> | Alias<number> |
| type_definitions.ts:22:32:22:37 | number | number |

View File

@@ -1,5 +1,5 @@
{
"compilerOptions": {
"lib": ["es2015.symbol"]
"lib": ["es2015"]
}
}