fix: make sure props are always defined

fix #7
This commit is contained in:
Géry Debongnie
2019-03-22 09:28:56 +01:00
parent add380f59b
commit a236ae396a
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -48,7 +48,7 @@ export interface Type<T> extends Function {
export class Component<
T extends Env,
Props,
Props extends {},
State extends {}
> extends EventBus {
readonly __widget__: Meta<Env, Props>;
@@ -96,7 +96,7 @@ export class Component<
// Pro: if props is empty, we can create easily a widget
// Con: this is not really safe
// Pro: but creating widget (by a template) is always unsafe anyway
this.props = <Props>props;
this.props = <Props>props || <Props>{};
let id: number = getId();
let p: Component<T, any, any> | null = null;
if (parent instanceof Component) {