This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 889
/
test.ts.lint
86 lines (69 loc) · 3.11 KB
/
test.ts.lint
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
let x: Array<undefined> = [undefined] as undefined[];
~~~~~~~~~~~~~~~~ [0]
let xx: Array<object> = [];
~~~~~~~~~~~~~ [0]
let y: string[] = <Array<string>>["2"];
~~~~~~~~~~~~~ [0]
let z: Array = [3, "4"];
~~~~~ [0]
let u: Array<unknown> = [];
~~~~~~~~~~~~~~ [0]
let xx: Array<Array<number>> = [[1, 2], [3]];
~~~~~~~~~~~~~~~~~~~~ [0]
~~~~~~~~~~~~~ [0]
let yy: number[][] = [[4, 5], [6]];
let ya = [[1, "2"]] as[number, string][];
~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
type Arr<T> = Array<T>;
~~~~~~~~ [0]
type ParenthesisArr<T> = (T)[];
type DoubleParenthesisArr<T> = ((T))[];
// Ignore user defined aliases
let yyyy: Arr<Array<Arr<string>>[]> = [[[["2"]]]];
~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
interface ArrayClass<T> {
foo: Array<T>;
~~~~~~~~ [0]
bar: T[];
baz: Arr<T>;
xyz: this[];
}
function fooFunction(foo: Array<ArrayClass<string>>) {
return foo.map(e => e.foo);
}
function barFunction(bar: ArrayClass<String>[]) {
~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
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: ((c: number) => number)[];
~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
type fooUnion = Array<string|number|boolean>;
type barUnion = (string|number|boolean)[];
~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
type bazUnion = ((string|number|boolean))[];
~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
type fooIntersection = Array<string & number>;
type barIntersection = (string & number)[];
~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
type bazIntersection = ((string & number))[];
~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
namespace fooName {
type BarType = { bar: string };
type BazType<T> = Arr<T>;
}
let v: Array<fooName.BarType> = [{ bar: "bar" }];
~~~~~~~~~~~~~~~~~~~~~~ [0]
let w: fooName.BazType<string>[] = [["baz"]];
~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.]
interface FooInterface {
'.bar': {baz: string[];};
}
// Test an unknown Array
let t: unknown[] = [];
let u: Array<unknown> = [];
~~~~~~~~~~~~~~ [0]
[0]: Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead.