[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
+16
View File
@@ -4,9 +4,25 @@ import type { ComponentNode } from "./component_node";
// Component Class
// -----------------------------------------------------------------------------
type Props = { [key: string]: any };
interface StaticComponentProperties {
template: string;
defaultProps?: any;
props?: any;
}
export type ComponentConstructor<P extends Props = any, E = any> = (new (
props: P,
env: E,
node: ComponentNode
) => Component<P, E>) &
StaticComponentProperties;
export class Component<Props = any, Env = any> {
static template: string = "";
static props?: any;
static defaultProps?: any;
props: Props;
env: Env;