Specifying onClick event type with Typescript and React.Konva

Posted by Prem Tiwari | Updated on

Specifying onClick event type with Typescript and React.Konva. As posted in my update above, a potential solution would be to use Declaration Merging as suggested by @Tyler-sebastion. I was able to define two additional interfaces and add the index property on the EventTarget in this way.

I then can declare the event as KonvaMouseEvent in my onclick MouseEventHandler function.

I’m still not 100% if this is the best approach as it feels a bit Kludgy and overly verbose just to get past the tslint error.

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers