Skip to content

Commit d9bbacf

Browse files
committed
refactor: strict unit interface typing
1 parent 75be6c0 commit d9bbacf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1172
-1160
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"prettier-plugin-organize-imports": "3.2.3",
8585
"shx": "0.3.3",
8686
"ts-node": "10.4.0",
87-
"typescript": "5.3.3",
87+
"typescript": "5.5.3",
8888
"typescript-eslint": "0.0.1-alpha.0"
8989
}
9090
}

src/Class/Element/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export type ElementEE<_EE extends Dict<any[]>> = StatefulEvents<
4040
Element_EE
4141

4242
export class Element_<
43-
I = any,
44-
O = any,
43+
I extends Dict<any> = any,
44+
O extends Dict<any> = any,
4545
_J extends Dict<any> = {},
4646
_EE extends ElementEE<_EE> = ElementEE<Element_EE>,
4747
_C extends Component = Component,
@@ -57,7 +57,6 @@ export class Element_<
5757
public _parent_children: Component_[] = []
5858
public _slot: Dict<Component_> = {}
5959
public _component: _C
60-
public _state: Dict<any> = {}
6160
public _animations: AnimationSpec[] = []
6261
public _stopPropagation: Dict<number> = {}
6362
public _stopImmediatePropagation: Dict<number> = {}
@@ -164,22 +163,19 @@ export class Element_<
164163
return removeParentChild(this, this._parent_children, component)
165164
}
166165

167-
appendChild(bundle: UnitBundle<Component_>): number {
166+
appendChild(bundle: UnitBundle): number {
168167
return appendChild(this, this._children, bundle)
169168
}
170169

171-
appendChildren(bundles: UnitBundle<Component_<ComponentEvents>>[]): number {
170+
appendChildren(bundles: UnitBundle[]): number {
172171
return appendChildren(this, this._children, bundles)
173172
}
174173

175-
insertChild(
176-
Bundle: UnitBundle<Component_<ComponentEvents>>,
177-
at: number
178-
): void {
174+
insertChild(Bundle: UnitBundle, at: number): void {
179175
throw new MethodNotImplementedError()
180176
}
181177

182-
pushChild(Bundle: UnitBundle<Component_>): number {
178+
pushChild(Bundle: UnitBundle): number {
183179
return pushChild(this, this._children, Bundle)[0]
184180
}
185181

src/Class/Functional/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Functional<
5151
this.addListener('destroy', this.d)
5252
}
5353

54-
private _on_input_data(name: string): void {
54+
private _on_input_data<K extends keyof I>(name: K): void {
5555
if (this._i[name] !== undefined && this._i_active.size === this._i_count) {
5656
this._looping = false
5757
}
@@ -74,28 +74,28 @@ export class Functional<
7474
}
7575
}
7676

77-
private _on_input_invalid(name: string): void {
77+
private _on_input_invalid<K extends keyof I>(name: K): void {
7878
if (this._i_invalid.size === 1) {
7979
this.d()
8080
this._invalidate()
8181
}
8282
}
8383

84-
onDataInputData(name: string): void {
84+
onDataInputData<K extends keyof I>(name: K): void {
8585
this._on_input_data(name)
8686
}
8787

88-
onDataInputDrop(name: string, data: any): void {
88+
onDataInputDrop<K extends keyof I>(name: K, data: any): void {
8989
this._on_input_drop()
9090
}
9191

92-
onDataInputStart(name: string): void {
92+
onDataInputStart<K extends keyof I>(name: K): void {
9393
if (this._i_start.size === this._i_count) {
9494
this._start()
9595
}
9696
}
9797

98-
onDataInputInvalid(name: string): void {
98+
onDataInputInvalid<K extends keyof I>(name: K): void {
9999
this._on_input_invalid(name)
100100
}
101101

@@ -109,20 +109,20 @@ export class Functional<
109109
this._on_input_data(name)
110110
}
111111

112-
onRefInputDrop(name: string, data: any): void {
112+
onRefInputDrop<K extends keyof I>(name: K, data: any): void {
113113
this._on_input_drop()
114114
}
115115

116-
onRefInputInvalid(name: string): void {
116+
onRefInputInvalid<K extends keyof I>(name: K): void {
117117
this._on_input_invalid(name)
118118
}
119119

120-
private _on_data_output_drop = (name: string): void => {
120+
private _on_data_output_drop = <K extends keyof O>(name: K): void => {
121121
this._backward_if_ready()
122122
this._forward_if_ready()
123123
}
124124

125-
onDataOutputDrop(name: string) {
125+
onDataOutputDrop<K extends keyof O>(name: K) {
126126
this._on_data_output_drop(name)
127127
}
128128

0 commit comments

Comments
 (0)