[IMP] typing: make app and mount method properly generic

This commit is contained in:
Géry Debongnie
2022-01-27 14:28:01 +01:00
committed by Aaron Bohy
parent add5fdd737
commit ff734c706c
4 changed files with 55 additions and 36 deletions
+4 -6
View File
@@ -1,6 +1,6 @@
import type { App, Env } from "../app/app";
import { BDom, VNode } from "../blockdom";
import { Component } from "./component";
import { Component, ComponentConstructor } from "./component";
import {
Fiber,
makeChildFiber,
@@ -74,13 +74,11 @@ export function component(
type LifecycleHook = Function;
export class ComponentNode<T extends typeof Component = typeof Component>
implements VNode<ComponentNode>
{
export class ComponentNode<P = any, E = any> implements VNode<ComponentNode<P, E>> {
el?: HTMLElement | Text | undefined;
app: App;
fiber: Fiber | null = null;
component: InstanceType<T>;
component: Component<P, E>;
bdom: BDom | null = null;
status: STATUS = STATUS.NEW;
@@ -99,7 +97,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
patched: LifecycleHook[] = [];
willDestroy: LifecycleHook[] = [];
constructor(C: T, props: any, app: App, parent?: ComponentNode) {
constructor(C: ComponentConstructor<P, E>, props: P, app: App, parent?: ComponentNode) {
currentNode = this;
this.app = app;
this.parent = parent || null;