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
127 lines (94 loc) · 3.29 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function func(): void {}
type NormalType = () => void;
let normalArrow = (): void => { }
let ughThisThing = void 0;
function takeThing(thing: undefined) { }
takeThing(void 0);
function takeVoid(thing: void) { }
~~~~ [0]
const arrowGeneric = <T extends void>(arg: T) => { }
~~~~ [0]
#if typescript >= 2.3.0
const arrowGeneric1 = <T = void>(arg: T) => { }
~~~~ [0]
const arrowGeneric2 = <T extends void = void>(arg: T) => { }
~~~~ [0]
~~~~ [0]
#endif
#if typescript >= 2.3.0
function functionGeneric<T extends void>(arg: T) {}
~~~~ [0]
function functionGeneric1<T = void>(arg: T) {}
~~~~ [0]
function functionGeneric2<T extends void = void>(arg: T) {}
~~~~ [0]
~~~~ [0]
#endif
declare function functionDeclaration<T extends void>(arg: T): void;
~~~~ [0]
#if typescript >= 2.3.0
declare function functionDeclaration1<T = void>(arg: T): void;
~~~~ [0]
declare function functionDeclaration2<T extends void = void>(arg: T): void;
~~~~ [0]
~~~~ [0]
#endif
functionGeneric<void>(undefined);
~~~~ [0]
declare function voidArray(args: void[]): void[];
~~~~ [0]
~~~~ [0]
let value = undefined as void;
~~~~ [0]
let value = <void>undefined;
~~~~ [0]
function takesThings(...things: void[]): void { }
~~~~ [0]
type KeyofVoid = keyof void;
~~~~[0]
interface Interface {
lambda: () => void;
voidProp: void;
~~~~ [0]
}
class ClassName {
private readonly propName: void;
~~~~ [0]
}
let voidPromise: Promise<void> = new Promise<void>(() => {});
let voidMap: Map<string, void> = new Map<string, void>();
let letVoid: void;
~~~~ [0]
type VoidType = void;
~~~~ [0]
class OtherClassName {
private propName: VoidType;
}
type UnionType = string | number;
type UnionType2 = string | number | void;
~~~~ [0]
type UnionType3 = string | (number & any | (string | void));
~~~~ [0]
type IntersectionType = string & number & void;
~~~~ [0]
function returnsVoidPromiseDirectly(): Promise<void> {
return Promise.resolve();
}
async function returnsVoidPromiseAsync(): Promise<void> {}
#if typescript >= 2.8.0
type MappedType<T> = {
[K in keyof T]: void;
~~~~ [0]
}
type ConditionalType<T> = {
[K in keyof T]: T[K] extends string ? void : string;
~~~~ [0]
}
#endif
#if typescript >= 3.4.0
type ManyVoid = readonly void[];
~~~~ [0]
function foo(arr: readonly void[]) { }
~~~~ [0]
#endif
[0]: void is only valid as a return type or generic type variable