mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
JS: Update qhelp and added more examples.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
declare class Point {
|
||||
// BAD: Using 'constructor' in an interface creates a method, not a constructor signature
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x : number, y: number);
|
||||
constructor(x: number, y: number); // This is just a method named "constructor"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// BAD: Using 'new' in a class creates a method, not a constructor
|
||||
class Point {
|
||||
x: number;
|
||||
y: number;
|
||||
new(x: number, y: number) {}; // This is just a method named "new"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// GOOD: Using 'constructor' for constructors in classes
|
||||
class Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number) { // This is a proper constructor
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
// GOOD: Using 'new' for constructor signatures in interfaces
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
new(x: number, y: number): Point; // This is a proper constructor signature
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// BAD: Using 'function' as a method name is confusing
|
||||
interface Calculator {
|
||||
function(a: number, b: number): number; // This is just a method named "function"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// GOOD: Using descriptive method names instead of 'function'
|
||||
interface Calculator {
|
||||
calculate(a: number, b: number): number; // Clear, descriptive method name
|
||||
}
|
||||
Reference in New Issue
Block a user