MithrilJS / mithril.d.ts

Types for mithril.js
MIT License
80 stars 11 forks source link

Cannot access ClassComponent members through vnode.state #21

Open spacejack opened 7 years ago

spacejack commented 7 years ago

In this case:

class C1 implements ClassComponent<{}> {
    foo = 1;
    view() {
        return m('p', 'foo = ' + this.foo);
    }
}

class C2 implements ClassComponent<{}> {
    view() {
        return m(C1, {
                    onremove(vnode) {
                        const n: number = vnode.state.foo; // <-- thinks state type is {}
                    }
                });
    }
}
idlist commented 3 years ago

The bug still exists for Mithril 2.0.4 and Mithril.d.ts 2.0.7, forcing me using Vnode instead of CVnode for Class components.