This repository was archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathNoStringBasedSetIntervalTestInput.ts
57 lines (54 loc) · 2.04 KB
/
NoStringBasedSetIntervalTestInput.ts
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
var typedStringVariable = 'string variable';
var functionVariable = () => {};
var anyVariable: any = () => {};
var createFunction: () => (() => void) = () => {
return () => {};
}; // function that produces a function
var untypedCreateFunction: () => any = () => {}; // function that produces a function
var stringFunction: () => string = () => {
return '';
}; // function that produces a string
// lambdas are OK
setInterval(() => {});
this.setInterval(() => {});
window.setInterval(() => {});
// functions are OK
setInterval(function() {});
this.setInterval(function() {});
window.setInterval(function() {});
// expressions of type function are OK
setInterval(functionVariable);
this.setInterval(functionVariable);
window.setInterval(functionVariable);
var a = setInterval(functionVariable);
var b = this.setInterval(functionVariable);
var c = window.setInterval(functionVariable);
setInterval(createFunction());
this.setInterval(createFunction());
window.setInterval(createFunction());
// this used to be a false positive.
function invokeInterval(functionArg: () => void) {
setInterval(functionArg);
}
// these should all create violations
setInterval("var x = 'should fail'"); // example 1
setInterval(typedStringVariable); // example 2
setInterval(anyVariable); // example 3
setInterval(untypedCreateFunction()); // example 4
setInterval(stringFunction()); // example 5
this.setInterval("var x = 'should fail'"); // example 6
this.setInterval(typedStringVariable); // example 7
this.setInterval(anyVariable); // example 8
this.setInterval(untypedCreateFunction()); // example 9
this.setInterval(stringFunction()); // example 10
window.setInterval("var x = 'should fail'"); // example 11
window.setInterval(typedStringVariable); // example 12
window.setInterval(anyVariable); // example 13
window.setInterval(untypedCreateFunction()); // example 14
window.setInterval(stringFunction()); // example 15
function invokInterval2(stringArg: string) {
setInterval(stringArg); // example 16
}
function invokeInterval3(anyArg: any) {
setInterval(anyArg); // example 17
}