made rungs generic
This commit is contained in:
10
lib/Rung.ts
10
lib/Rung.ts
@@ -2,12 +2,12 @@ import {SubNode} from "./helpers";
|
|||||||
|
|
||||||
export type RungOptions = {};
|
export type RungOptions = {};
|
||||||
|
|
||||||
export default abstract class Rung {
|
export default abstract class Rung<NodeType extends Node = Node> {
|
||||||
protected node: Node | null = null;
|
protected node: NodeType | null = null;
|
||||||
|
|
||||||
protected constructor(options: RungOptions) {}
|
protected constructor(options: RungOptions) {}
|
||||||
|
|
||||||
render(): Node {
|
render(): NodeType {
|
||||||
if (!this.node) {
|
if (!this.node) {
|
||||||
this.node = this.build();
|
this.node = this.build();
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ export default abstract class Rung {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract build(): Node;
|
protected abstract build(): NodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FunctionalRung<Props extends Record<string, any>, N extends HTMLElement> = (attributes: Props, subNodes?: SubNode[]) => N;
|
export type FunctionalRung<Props extends Record<string, any>, N extends Node = Node> = (attributes: Props, subNodes?: SubNode[]) => N;
|
||||||
|
|||||||
Reference in New Issue
Block a user