forked from palantir/tslint
/
test.ts.fix
65 lines (48 loc) · 1.47 KB
/
test.ts.fix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
let x: undefined[] = [undefined] as undefined[];
let xx: object[] = [];
let y: string[] = <string[]>["2"];
let z: any[] = [3, "4"];
let u: unknown[] = [];
let xx: number[][] = [[1, 2], [3]];
let yy: number[][] = [[4, 5], [6]];
let ya = [[1, "2"]] as Array<[number, string]>;
type Arr<T> = T[];
type ParenthesisArr<T> = (T)[];
type DoubleParenthesisArr<T> = ((T))[];
// Ignore user defined aliases
let yyyy: Arr<Array<Array<Arr<string>>>> = [[[["2"]]]];
interface ArrayClass<T> {
foo: T[];
bar: T[];
baz: Arr<T>;
xyz: this[];
}
function fooFunction(foo: Array<ArrayClass<string>>) {
return foo.map(e => e.foo);
}
function barFunction(bar: Array<ArrayClass<String>>) {
return bar.map(e => e.bar);
}
function bazFunction(baz: Arr<ArrayClass<String>>) {
return baz.map(e => e.baz);
}
let fooVar: Array<(c: number) => number>;
let barVar: Array<(c: number) => number>;
type fooUnion = Array<string|number|boolean>;
type barUnion = Array<string|number|boolean>;
type bazUnion = Array<(string|number|boolean)>;
type fooIntersection = Array<string & number>;
type barIntersection = Array<string & number>;
type bazIntersection = Array<(string & number)>;
namespace fooName {
type BarType = { bar: string };
type BazType<T> = Arr<T>;
}
let v: fooName.BarType[] = [{ bar: "bar" }];
let w: Array<fooName.BazType<string>> = [["baz"]];
interface FooInterface {
'.bar': {baz: string[];};
}
// Test an unknown Array
let t: unknown[] = [];
let u: unknown[] = [];