Unexpected class with only static properties
5import ComponentPort from "@/app/core/componentPort";
6import { Point } from "@/app/core/init";
7
8export default class ComponentPortRenderer2D { 9 static renderComponentPort(componentport: ComponentPort, draworigin: Point, geoCenter: Point, rotation: number, mirrorByX: number, mirrorByY: number, portrendersize: number = 500) {
10 const xpos = draworigin[0];
11 const ypos = draworigin[1];
Unexpected class with only static properties
27 DeviceInterchangeV1_1
28} from "@/app/core/init";
29
30export default class LoadUtils { 31 constructor() {}
32
33 static loadFromScratch(json: InterchangeV1_2): [Device, Array<RenderLayer>] {
Description
Using class as a namespace can lead to errors.
Bad Practice
class EmptyClass {}
class ConstructorOnly {
constructor() {
foo();
}
}
// Use an object instead:
class StaticOnly {
static version = 42;
static hello() {
console.log('Hello, world!');
}
}
Recommended
class EmptyClass extends SuperClass {}
class ParameterProperties {
constructor(public name: string) {}
}
const StaticOnly = {
version: 42,
hello() {
console.log('Hello, world!');
},
};