React SynteticEvent provides no blur() method for KeyboardEvent<HTMLInputElement>

Viewed 882

When I try to use blur() method for target received from KeyboardEvent<HTMLInputElement> I have TypeScript error:

Property 'blur' does not exist on type 'EventTarget'.ts(2339)

while same code works perfectly for target received from FocusEvent<HTMLInputElement>

The origin of this - KeyboardEvent target has EventTarget type, while FocusEvent gives EventTarget & HTMLInputElement.

Is this React.KeyboardEvent bug or how do I use types properly here without casting via as?

enter image description here

TS issue demo on StackBlitz

0 Answers
Related