TypeScript: DataTable: Property 'value' does not exist on EventTarget (ts2339)
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57
Sandbox The error exists & is shown in the sandbox (but there it compiles - less strict, I guess): https://codesandbox.io/s/3vpem?file=/src/demo/DataTableEditDemo.tsx
Current behavior If the example code is written as TS in Visual Studio Code, then it is currently not possible to compile it.
In the following line e is considered only a generic EventTarget of an HTMLElement, not having a value, and not - as far as I understand - as EventTarget of an HTMLInputElement:
const inputTextEditor = (props: any, field: string) => {
return <InputText type="text" value={props.rowData[field]} onChange={(e) => onEditorValueChange(props, e.target.value)} />;
};
Expected behavior Example code compiles without warnings.
Minimal reproduction of the problem with instructions See sandbox link above.
My solution (at least it compiles, I am a beginner):
const inputTextEditor = (props: any, field: string) => {
return <InputText type="text" value={props.rowData[field]} onChange={(e: React.ChangeEvent<HTMLInputElement>) => onEditorValueChange(props, e.target.value)} />;
};
Please tell us about your environment: Irrelevant, but Windows, Chrome, VSCode, TypeScript.
-
React version: Current: ^16.13.1
-
PrimeReact version: Current: ^4.2.1
-
Browser: Irrelevant, all
-
Language: TypeScript ~3.9.3 | ES5
Regards, HerrB92
This demo is no longer available. You can check new one from https://primefaces.org/primereact/showcase/#/datatable/edit .