Fixing “Property ‘value’ does not exist on type ‘EventTarget'” in TypeScript
The TypeScript error "Property 'value' does not exist on type 'EventTarget'." appears when you read value from e.target in an event handler. The type of e.target is EventTarget, which does not tell TypeScript which element fired the event. With addEventListener, you can check with instanceof HTMLInputElement. In React, you can read e.currentTarget.value or use onChange. Either way, the error goes away.
This error appears when you read the text typed into a form input, for example in an input event listener added with addEventListener, or in an onInput handler in React. I triggered this error in my test environment with both tsc and the language server that editors use. I checked the full message text and confirmed that the error disappears after each fix. I also ran the fixed code in a browser and confirmed that it can read the typed text.
The test environment was Ubuntu 24.04 with Node.js 22.23.4. I used TypeScript 7.0.2, React 19.3.1, and @types/react 19.3.0. For comparison, I also ran tsc on the same files with TypeScript 5.9.3 and 6.0.3. For the editor display, I did not use the editor itself (such as VS Code). Instead, I ran the language server built into the TypeScript 7 tsc (tsc --lsp --stdio) directly. The browser was Chromium 153, driven by Playwright. I did not check how the error looks in VS Code, and I did not test other frameworks such as Vue.
The full error
In the test environment, I installed TypeScript 7.0.2 in an empty folder and created tsconfig.json with npx tsc --init. The generated tsconfig.json contained "strict": true. There was no lib setting, so the browser DOM types were available as usual.
In src/dom-input.ts, I wrote code that adds an input event listener to the input with id name and displays the typed text.
const input = document.querySelector<HTMLInputElement>("#name");
input?.addEventListener("input", (e) => {
console.log(e.target.value);
});
Running npx tsc --noEmit produced the following two lines for this file (exit code 1). The src folder also contained other files that appear later in this article, so only the lines for this file are shown here.
src/dom-input.ts(4,15): error TS18047: 'e.target' is possibly 'null'.
src/dom-input.ts(4,24): error TS2339: Property 'value' does not exist on type 'EventTarget'.
With --pretty, the problem locations are shown with squiggly underlines. The control characters for color are removed, and the output for other files and the final summary are omitted.
src/dom-input.ts:4:15 - error TS18047: 'e.target' is possibly 'null'.
4 console.log(e.target.value);
~~~~~~~~
src/dom-input.ts:4:24 - error TS2339: Property 'value' does not exist on type 'EventTarget'.
4 console.log(e.target.value);
~~~~~
There are two errors. The first, TS18047, means "e.target may be null." The second, TS2339, is the error in this article. It means "the EventTarget type has no property named value." The underline is on value.
Adding ?. as in e.target?.value removes TS18047, but TS2339 remains.
src/dom-input-chain.ts(4,25): error TS2339: Property 'value' does not exist on type 'EventTarget'.
The same error appears in the editor
A language server sends diagnostics (the error locations and messages) to the editor. See the diagnostic section of the Language Server Protocol specification. The TypeScript 7 tsc can also run as a language server. See the explanation in the TypeScript 7 port repository. I started the TypeScript 7.0.2 language server with tsc --lsp --stdio and opened src/dom-input.ts the same way an editor does. It returned the following diagnostics. I used a small script of my own to format the returned JSON as one line per diagnostic (hover results are omitted).
server: typescript-go 7.0.2
diagnostics (2):
4:15-4:23 severity=1 source=ts code=18047 'e.target' is possibly 'null'.
4:24-4:29 severity=1 source=ts code=2339 Property 'value' does not exist on type 'EventTarget'.
4:24-4:29 means from character 24 to just before character 29 on line 4. This matches the underline under value in the tsc --pretty output. severity=1 is the LSP value for an error, and code=2339 is TS2339. The message text was the same as in tsc.
Why e.target is typed as EventTarget
When I hovered over target in e.target, the language server showed (property) Event.target: EventTarget | null. In the DOM types TypeScript uses, the target of Event is EventTarget | null. Even if the listener is attached to an input field, TypeScript does not narrow it to HTMLInputElement.
target refers to the element where the event happened. See the MDN explanation of Event.target. Events bubble from child elements up to parent elements, so the element with the listener and target are not always the same. The element with the listener is referred to by currentTarget. See the MDN explanation of Event.currentTarget. TypeScript cannot know which element the event came from, so it types target as EventTarget, which does not have a value property.
This error exists only at the type level. I ran the original src/dom-input.ts in a browser without type checking (after removing the type annotations with esbuild). When I typed "neko" into the input, the console showed the following.
n
ne
nek
neko
The value can be read at runtime, but TypeScript cannot tell that e.target is the input field.
Three ways to fix it with addEventListener
Use the variable the listener is attached to
If you have a variable holding the input that the listener is attached to, the simplest fix is to read value from that variable and skip e.target.
const input = document.querySelector<HTMLInputElement>("#name");
input?.addEventListener("input", () => {
console.log("closure:", input.value);
});
The type of the querySelector result is HTMLInputElement | null. However, when I hovered over input inside the listener, it showed const input: HTMLInputElement, so null had been removed.
Check with instanceof whether it is the input
When one listener receives events from several elements (for example, when you attach it to a parent element), you have to use e.target. In that case, check with instanceof whether the target is an input field.
const input = document.querySelector<HTMLInputElement>("#name");
input?.addEventListener("input", (e) => {
if (e.target instanceof HTMLInputElement) {
console.log("instanceof:", e.target.value);
}
});
After the if check, TypeScript narrows the type of e.target. See the Handbook section on narrowing with instanceof. When I hovered over e.target on the if line, it showed EventTarget | null. Inside the if block, it showed HTMLInputElement. The instanceof check also removes null, so TS18047 disappears too.
Specify the type with as
Using as to tell TypeScript that the target is an input field also removes the error.
const input = document.querySelector<HTMLInputElement>("#name");
input?.addEventListener("input", (e) => {
const target = e.target as HTMLInputElement;
console.log("as:", target.value);
});
as only specifies a type. It does not check anything at runtime (see the Handbook section on type assertions). Even if e.target is not an input field, TypeScript will not report an error. When you cannot tell which element fired the event, use instanceof to check it instead.
In React, whether the error appears depends on onChange vs onInput
React also produces this error, but whether it appears depends on the event type. I passed functions written the same way to onChange and onInput, as shown below.
import { useState } from "react";
export function InlineFields() {
const [name, setName] = useState("");
return (
<>
<input value={name} onChange={(e) => setName(e.target.value)} />
<input value={name} onInput={(e) => setName(e.target.value)} />
</>
);
}
tsc reported only one error, on line 9, which is the onInput handler.
src/react-inline.tsx(9,60): error TS2339: Property 'value' does not exist on type 'EventTarget'.
Hovering over the e parameters showed React.ChangeEvent<HTMLInputElement, HTMLInputElement> for onChange and React.InputEvent<HTMLInputElement> for onInput.
In the React types (@types/react 19.3.0), target on SyntheticEvent, the base of the event types, is EventTarget. currentTarget has the type of the element with the handler, such as EventTarget & HTMLInputElement. InputEvent follows this pattern, but ChangeEvent also types target as the element type. According to a comment in the type definitions, form elements that emit change events are never nested, so target is known to be an <input>. The official React reference example for controlling an input with state also uses onChange={e => setFirstName(e.target.value)}. See the <input> reference, the example controlling an input with a state variable.
For events other than ChangeEvent, such as onInput, read the value with e.currentTarget.value. The same applies when you write the function separately and give it a type, as shown below.
import { useState, type InputEvent } from "react";
export function NameField() {
const [name, setName] = useState("");
const handleInput = (e: InputEvent<HTMLInputElement>) => {
setName(e.currentTarget.value);
};
return (
<>
<input id="react-name" value={name} onInput={handleInput} />
<p id="react-out">{name}</p>
</>
);
}
In the file where I used e.target.value inside handleInput, I got src/react-input.tsx(7,22): error TS2339: Property 'value' does not exist on type 'EventTarget'. In the fixed file, hovering over e.currentTarget showed the type EventTarget & HTMLInputElement. The React reference also describes currentTarget as the element the handler is attached to, and target as the element where the event happened, which may be a child element further down. See the React explanation of the event object.
When you write a separate function for onChange, give it the type ChangeEvent<HTMLInputElement>. Then e.target.value works without errors.
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
setName(e.target.value);
};
When I used FormEvent<HTMLInputElement>, e.target.value produced the same TS2339. The language server also returned a diagnostic 'FormEvent' is deprecated. (severity=4, which the LSP specification treats as a hint rather than an error). The @types/react 19.3.0 type definitions say that FormEvent is not a real event type and recommend using ChangeEvent, InputEvent, SubmitEvent, and similar types instead.
Confirming the errors are gone after the fixes
I placed only the fixed files from above in src (the variable approach, instanceof, as, React's currentTarget, and ChangeEvent) and ran npx tsc --noEmit. It printed nothing and exited with code 0. When the language server opened the files, every file returned diagnostics (0):, with no errors.
I ran the fixed code together in a browser and typed "neko" into each input field. The three addEventListener variants displayed the typed text on every keystroke. The last line of each is shown below. The two React components also displayed "neko" in the paragraph below each input. The react-out: and react-out2: lines are the text from those paragraphs, read and printed by my test script.
closure: neko
instanceof: neko
as: neko
react-out: neko
react-out2: neko
TypeScript 5.9.3 and 6.0.3 also reported errors with the same numbers and messages on the original files. The exit code of tsc was 2 for 5.9.3 and 6.0.3, and 1 for 7.0.2.




