I have a component, that has onClick prop.
I'm passing it an async handler, and getting the error:
Type '() => Promise' is not assignable to type 'EventHandler<ClickEvent, boolean | void>'. Type 'Promise' is not assignable to type 'boolean | void'. Type 'Promise' is not assignable to type 'void'.ts(2322)
Code
onClick={async () => {
await item.onClick();
menuRenderParams.closeMenu();
}}
I tried using named handler _onClick, and specify the return type, but it didn't work.
While using the named handler I tried give the handler type like this: _onClick: EventHandler but got this error:
Generic type 'EventHandler' requires 1 type argument(s).
I look around for typescript promise handler type but didn't found anything.
- side note, I added
"strict": falseto the .tsconfig, but the compilation still fails. if you could help me understand this also it would be gr8.