ClassComponent lifecycle method vnode types
vrimar opened this issue · 5 comments
Any reason as to why the lifecycle method vnode types for ClassComponents are m.Vnode/m.VnodeDOM
and not m.CVnode/m.CVnodeDOM
?
I can submit a PR if need be.
The reason being that vnode.state
should have your class properties on it.
That said... I notice that the view
vnode type is CVnode<A>
, and should be Vnode<A, this>
:/
But Typescript can't infer these types in your class methods, so you end up having to write them out anyway.
Ah, I see. I write my components like:
interface IAttrs {
// ...attrs
}
class Component<A> implements m.ClassComponent<A> {
prop: boolean = false;
someOtherProp: number = 0;
oninit(vnode: m.CVnode<IAttrs>) {
this.prop = true;
this.someOtherProp = 1;
}
view() {}
}
so I don't need the type safety on vnode.state
but it definitely should be there.
Yes, if you're using classes, you probably don't use vnode.state
.
Once this feature is released however, there may be more use for it.
Anyway thanks, I'll fix the view
signature.
Ok, sounds good.
Fix in this branch.