mithril.d.ts icon indicating copy to clipboard operation
mithril.d.ts copied to clipboard

Cannot access ClassComponent members through vnode.state

Open spacejack opened this issue 8 years ago • 1 comments

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 {}
                    }
                });
	}
}

spacejack avatar May 06 '17 01:05 spacejack

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.

idlist avatar May 30 '21 13:05 idlist