I'm using fresh on Deno. In islands, what is the type of an event like below?
export function Sample() {
return (
<input
type="file"
onChange={(e) => ...} // what is this `e`'s type???
/>
);
}
I also want to write like here.
export function Sample() {
const onChangeHandler = (e: ?) => { // e's type??? How can I import the type????
...
}
return (
<input
type="file"
onChange={onChangeHandler} // what is this `e`'s type???
/>
);
}
The type seems to be JSXInternal.TargetedEvent<HTMLInputElement, Event>
, Is this right? How can I import this type from fresh?
export function Sample() {
const onChangeHandler = (e: Event) => { // the answer. doesn't need any import lines.
const input = e.target as HTMLInputElement; // use cast
const selectedFile = input.files?.[0];
...
}
return (
<input
type="file"
onChange={onChangeHandler} // what is this `e`'s type???
/>
);
}
My code is above. This didn't need any import lines.