Skip to content

Commit 41f4236

Browse files
committed
JS: expanded suspicious-method-name-declaration test suite
1 parent 75caa18 commit 41f4236

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

javascript/ql/test/query-tests/Declarations/SuspiciousMethodNameDeclaration/SuspiciousMethodNameDeclaration.expected

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@
22
| tst.ts:16:3:16:21 | function(): number; | The member name 'function' does not declare a function, it declares a method named 'function'. |
33
| tst.ts:37:3:37:21 | function(): number; | The member name 'function' does not declare a function, it declares a method named 'function'. |
44
| tst.ts:48:3:48:13 | new(): Quz; | The member name 'new' does not declare a constructor, but 'constructor' does in class declarations. |
5+
| tst.ts:60:3:60:21 | function(): number; | The member name 'function' does not declare a function, it declares a method named 'function'. |
6+
| tst.ts:64:3:64:24 | constru ... number; | The member name 'constructor' does not declare a constructor in interfaces, but it does in classes. |
7+
| tst.ts:74:3:74:30 | functio ... string; | The member name 'function' does not declare a function, it declares a method named 'function'. |
8+
| tst.ts:75:3:75:30 | functio ... number; | The member name 'function' does not declare a function, it declares a method named 'function'. |
9+
| tst.ts:76:3:76:24 | functio ... ): any; | The member name 'function' does not declare a function, it declares a method named 'function'. |
10+
| tst.ts:80:3:80:23 | abstrac ... : void; | The member name 'new' does not declare a constructor, but 'constructor' does in class declarations. |
11+
| tst.ts:84:3:84:30 | abstrac ... number; | The member name 'function' does not declare a function, it declares a method named 'function'. |
12+
| tst.ts:93:5:93:21 | function(): void; | The member name 'function' does not declare a function, it declares a method named 'function'. |
13+
| tst.ts:98:3:98:21 | function(): number; | The member name 'function' does not declare a function, it declares a method named 'function'. |
14+
| tst.ts:110:3:110:24 | constru ... number; | The member name 'constructor' does not declare a constructor in interfaces, but it does in classes. |
15+
| tst.ts:116:3:116:24 | constru ... number; | The member name 'constructor' does not declare a constructor in interfaces, but it does in classes. |

javascript/ql/test/query-tests/Declarations/SuspiciousMethodNameDeclaration/tst.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,70 @@ declare class Quz {
5050

5151
var bla = new Foo();
5252
var blab = new Baz();
53+
54+
55+
interface X {
56+
constructor: () => string; // Just a property, not a method.
57+
}
58+
59+
type A = {
60+
function(): number; // $ Alert
61+
};
62+
63+
type B = {
64+
constructor(): number; // $ Alert
65+
new(): number;
66+
};
67+
68+
class StaticMethods {
69+
static function(): void {}
70+
static new(): void {}
71+
}
72+
73+
interface Overloaded {
74+
function(x: string): string; // $Alert
75+
function(x: number): number; // $Alert
76+
function(x: any): any; // $Alert
77+
}
78+
79+
abstract class AbstractFoo {
80+
abstract new(): void; // $Alert
81+
}
82+
83+
abstract class AbstractFooFunction {
84+
abstract function(): number; // $Alert
85+
}
86+
87+
abstract class AbstractFooConstructor {
88+
constructor(){}
89+
}
90+
91+
declare module "some-module" {
92+
interface ModuleInterface {
93+
function(): void; // $Alert
94+
}
95+
}
96+
97+
type Intersection = {
98+
function(): number; // $Alert
99+
} & {
100+
other(): string;
101+
};
102+
103+
type Union = {
104+
new(): number;
105+
} | {
106+
valid(): string;
107+
};
108+
109+
type Union2 = {
110+
constructor(): number; // $Alert
111+
} | {
112+
valid(): string;
113+
};
114+
115+
type Intersection2 = {
116+
constructor(): number; // $Alert
117+
} & {
118+
other(): string;
119+
};

0 commit comments

Comments
 (0)