JSDoc: Property 'value' does not exist on type 'EventTarget'

I’m using vanilla JavaScript with TypeScript as pre-processor in combination with JSDoc.
That pretty much works flawlessly, especially in the backend (when using in NodeJS, for instance).

However, when I use it with DOM objects, things get a bit tricky.

For example: Say I have an HTML Input field, I catch the input event and want to access the input’s value with e.target.value:

 * Log data on input
 * @param {Event} e
let handleEvent = function(e){

document.getElementById("my-input").addEventListener("input", handleEvent);

This results in a TS warning:

Property ‘value’ does not exist on type ‘EventTarget’

As seen here:

TypeScript Warning

Now my question is, what’s the correct @param annotation?

So far I’ve tried Event, InputEvent and HTMLInputElement.

I don’t want to use Type-Assertion. Instead I’d like to know how to specify it in the functions annotations directly, so I do not have to set @type for each and every occurrence of e.target.value individually as suggested here.

81 thoughts on “JSDoc: Property 'value' does not exist on type 'EventTarget'”

  1. This is probably what you need:
    Notice the {target: HTMLInputElement}.
    The reason why this works is that you’re basically "extending" the Event class by the new target property – which already exists, so it gets overridden with our new type.

  2. What i do not understood is actually how you are now not really much more smartly-appreciated than you may be now.
    You are very intelligent. You recognize therefore significantly in terms of this
    topic, made me in my view imagine it from a lot of various angles.
    Its like women and men don’t seem to be fascinated until it is one thing to
    accomplish with Woman gaga! Your own stuffs nice. Always maintain it up!

    My homepage: home lpe88 download

  3. I really love your website.. Very nice colors & theme.
    Did you create this website yourself? Please reply back
    as I’m looking to create my very own blog and would love to learn where you got this from or exactly what the theme is named.

    Appreciate it!

  4. I drop a leave a response each time I like a article on a website or
    I have something to contribute to the conversation. It is triggered
    by the passion displayed in the post I read. And after
    this article JSDoc: Property 'value' does not exist on type 'EventTarget' –
    JavaScript Help. I was excited enough to post
    a leave a responsea response 🙂 I do have 2 questions for
    you if it’s allright. Could it be simply me or do some
    of the responses come across like left by brain dead
    folks? 😛 And, if you are posting on other online sites,
    I’d like to keep up with everything new you have to post.
    Would you make a list the complete urls of all your shared sites like your
    linkedin profile, Facebook page or twitter feed?

    Check out my homepage mintjasia.com

  5. Incredible! This blog looks just like my old one! It’s on a entirely different
    subject but it has pretty much the same layout and design. Superb choice of colors!

    Also visit my web page :: Rosaline

  6. We would like to thank you once again for the wonderful ideas you offered Jeremy when preparing her post-graduate
    research and also, most importantly, regarding providing every one of the ideas in one blog
    post. Provided we had been aware of your web-site a year ago, we may have
    been rescued from the unnecessary measures we were selecting.
    Thanks to you.

    My web page https://www.qiurom.com

  7. I do not even know the way I ended up here, however I believed this publish was once good.
    I don’t know who you are but definitely you’re going to a well-known blogger when you aren’t already.


    my web blog: kebe.top

  8. Whoah this weblog is great i love reading your posts.
    Keep up the good work! You recognize, many persons are looking around
    for this information, you could help them greatly.

    Also visit my web-site: kebe.top


Leave a Comment