Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give better error messages when properties are accessed on global empty DOM interfaces #33907

Closed
DanielRosenwasser opened this issue Oct 9, 2019 · 6 comments

Comments

@DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Oct 9, 2019

https://twitter.com/rauschma/status/1181852019264503808

We should give a more helpful message when missing "lib": ["dom"].

If accessing a property on a type that was

  • empty and
  • declared in the global scope and
  • named after a pattern that matches /^HTML\w+Element$/

it is likely a forward declaration for DOM environments, and we should provide an error message like:

Property '{0}' does not exist on type '{1}'. Did you forget to include "dom" in your "lib" setting?

Bonus: would be awesome if we could provide related spans in a tsconfig.json/jsconfig.json to say

The 'lib' option was specified here.
@m-henderson
Copy link

@m-henderson m-henderson commented Apr 30, 2020

@kyliau did you plan on picking this back up?

@kyliau
Copy link
Contributor

@kyliau kyliau commented Apr 30, 2020

@kyliau did you plan on picking this back up?

I think you meant @kylejlin

@kylejlin
Copy link

@kylejlin kylejlin commented Apr 30, 2020

@m-henderson No, I do not plan on picking this back up. You're welcome to take over, if that's why you're asking.

@m-henderson
Copy link

@m-henderson m-henderson commented May 1, 2020

Sorry about that @kyliau, your names are similar at first glance. Thanks for the response @kylejlin

@kyeb
Copy link

@kyeb kyeb commented Aug 4, 2020

I just spent 30+ minutes stuck on this error -- would love to see something like this get added so others don't go down that rabbit hole.

In my case, the cryptic error was Property 'value' does not exist on type 'EventTarget & HTMLInputElement', for a simple React onChange={(e) => setNewValue(e.target.value)}.

@DanielRosenwasser
Copy link
Member Author

@DanielRosenwasser DanielRosenwasser commented Apr 7, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment