-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
DOMStringMap can lead to easy type errors #13792
Comments
This proposal will make the two lines flagged as errors now.. but i suppose it is safer. |
That's a good point - I'd rather that happen. I will open a PR tomorrow. Is this a breaking change? |
it is a breaking change. marking it as such. |
After doing some more research, it seems as though I need to modify https://github.com/Microsoft/TSJS-lib-generator/blob/master/inputfiles/browser.webidl.xml According to the readme of that repo, these are generated by Edge. Does this make the issue a non-starter? |
you need to override https://github.com/Microsoft/TSJS-lib-generator/blob/master/inputfiles/overridingTypes.json instead. not the .xml file. |
Every object map can be undefined on a random key access. Can we catch this in a general approach or do we have to find every needed definition? |
@HolgerJeromin that's a good point. For numbers when access is array-like, including undefined doesn't make much sense but for strings it does. Does anyone else have opinions on this? |
I think even with array-like access it is easy possible to get an undefined value. I just changed my own code and had an issue with
I cannot imagine a case where |
TypeScript Version: 2.1.5 (bug is present on master)
Code
Expected behavior:
The project doesn't compile with a type error.
Actual behavior:
The project does compile, and a runtime error occurs.
This is caused by the fact that
DOMStringMap
's index return has typestring
, and notstring | undefined
.We want
To be
If this is approved, I am very happy to make a PR on this - and would like to do so to try and contribute to TypeScript codebase.
The text was updated successfully, but these errors were encountered: