I have the following code:
interface IHandleSelection {
(value: string): any | void;
}
interface IPipeChangeEventValueToFunction {
(handler: IHandleSelection): (event: React.ChangeEvent<HTMLSelectElement>) => void;
}
const pipeChangeEventValueToFunction: IPipeChangeEventValueToFunction = handler => event =>
handler(event.target.value);
...
// within a component where onSelection is a prop of type IHandleSelection
<select
onChange={pipeChangeEventValueToFunction(onSelection)}
>
On which I get the error:
Property 'value' does not exist on type 'EventTarget & HTMLSelectElement'
I've tried the fix suggested here (and elsewhere):
const pipeChangeEventValueToFunction: IPipeChangeEventValueToFunction = handler => event => {
const test = event.target as HTMLSelectElement;
const a = test.value;
}
But I get the exact same error (perhaps unsurprisingly).
Any thoughts on what's going on here? It seems like some sort of typing error.