This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
/
test.ts.lint
78 lines (62 loc) · 2.95 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
class C { }
enum MyEnum {
A, B, C
}
let anyType: {};
let boolType: boolean;
let boolType2: boolean;
let bwrapType: Boolean;
let numType = 9;
let strType = "string";
let objType = new Object();
let classType = new C();
let enumType = MyEnum.A;
let boolFn = () => { return true; };
let strFn = () => { return strType; };
let numFn = () => { return numType; };
let boolExpr = (strType !== undefined);
/*** Binary Expressions ***/
/*** Invalid Boolean Expressions ***/
classType && boolType;
~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.]
anyType && boolType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.]
numType && boolType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.]
boolType && strType;
boolType && objType && enumType;
boolType && objType || enumType;
boolType || objType && enumType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.]
boolType || objType || enumType;
bwrapType && boolType;
~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.]
boolType || classType;
boolType || anyType;
boolType || numType;
strType || boolType;
~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.]
bwrapType || boolType;
~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.]
objType || boolType || enumType;
~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.]
boolExpr && strType;
numType || boolExpr;
~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.]
numType && boolExpr || strType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.]
bwrapType || boolExpr && bwrapType;
~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.]
let bool1:boolean = true
let bool2:boolean = true
let obj:{}|undefined = {}
bool1 && obj && bool2
bool1 && bool2 && obj
boolExpr && numType || strType;
boolExpr || numType || strType;
boolExpr || numType && strType;
~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.]
boolExpr && numType && strType;
boolExpr || boolType && strType;
boolExpr || boolType || strType;
boolExpr && boolType || strType;