Skip to content

Commit 3ffcfdc

Browse files
authored
refactor: drop usage of dummy arguments for multi-inheritance (#54)
1 parent 3cf2e4d commit 3ffcfdc

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

src/ui/components/abstract/ScriptObject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ScriptObject extends FrameScriptObject {
1111

1212
_name: string | null;
1313

14-
constructor(_dummy: unknown) {
15-
super(_dummy);
14+
constructor(..._args: unknown[]) {
15+
super(..._args);
1616

1717
this._name = null;
1818
}

src/ui/components/abstract/ScriptRegion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class ScriptRegion extends multipleClasses(ScriptObject, LayoutFrame) {
1818

1919
_parent: Frame | null;
2020

21-
constructor(_dummy: unknown) {
22-
super(_dummy);
21+
constructor(..._args: unknown[]) {
22+
super(_args);
2323

2424
this._parent = null;
2525
}

src/ui/components/simple/Frame.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Frame extends ScriptRegion {
6666
strataLink: LinkedListLink<this>;
6767

6868
constructor(parent: Frame | null) {
69-
super(null);
69+
super();
7070

7171
this.id = 0;
7272
this.flags = 0;
@@ -189,7 +189,7 @@ class Frame extends ScriptRegion {
189189
}
190190
}
191191

192-
// TODO: Seems to be necessary with split getter/setters + inheritance
192+
// Note: Seems to be necessary with split getter/setters + inheritance
193193
get parent() {
194194
return this._parent;
195195
}

src/ui/components/simple/Region.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LinkedListLink } from '../../../utils';
55

66
import Frame from './Frame';
77

8-
abstract class Region extends ScriptRegion {
8+
class Region extends ScriptRegion {
99
drawLayerType: DrawLayerType | null;
1010
shown: boolean;
1111
visible: boolean;
@@ -17,7 +17,7 @@ abstract class Region extends ScriptRegion {
1717
regionLink: LinkedListLink<this>;
1818

1919
constructor(frame: Frame, drawLayerType: DrawLayerType, show: boolean) {
20-
super(null);
20+
super();
2121

2222
this.drawLayerType = null;
2323
this.shown = false;
@@ -34,7 +34,9 @@ abstract class Region extends ScriptRegion {
3434
}
3535
}
3636

37-
abstract draw(_batch: RenderBatch): void;
37+
draw(_batch: RenderBatch) {
38+
throw new Error(`${this.constructor.name} must implement 'draw'`);
39+
}
3840

3941
onRegionChanged() {
4042
// TODO: Implementation

src/ui/scripting/FrameScriptObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class FrameScriptObject {
3232
luaRef: lua_Ref | null;
3333
scripts: ScriptRegistry;
3434

35-
constructor(_dummy: unknown) {
35+
constructor(..._args: unknown[]) {
3636
this.luaRef = null;
3737

3838
this.scripts = new ScriptRegistry();

src/utils/inheritance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const multipleClasses = <
1616
}
1717

1818
const cls = class extends base {
19-
constructor(..._args: any[]) {
19+
constructor(...args: any[]) {
2020
// Create an instance of the base class
21-
super();
21+
super(...args);
2222

2323
// Construct temporary throw-away instance of other class and assign own properties
2424
// Warning: using `this` as a reference in other class' constructor will not work correctly

0 commit comments

Comments
 (0)