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

Better errors for indexing gettable/settable values #26098

Closed
DanielRosenwasser opened this issue Jul 31, 2018 · 5 comments · Fixed by #26446
Closed

Better errors for indexing gettable/settable values #26098

DanielRosenwasser opened this issue Jul 31, 2018 · 5 comments · Fixed by #26446
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@DanielRosenwasser
Copy link
Member

@sandersn found a case where, upon turning on noImplicitAny in Puppeteer, we issued the following error on a Map:

Element implicitly has an 'any' type because type 'Map<string, Function>' has no index signature.

We should give a more specialized error message in cases where there is no index signature, but the value has a method get that takes a string, or when

Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}'?
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Help Wanted You can do this Good First Issue Well scoped, documented and has the green light Domain: Error Messages The issue relates to error messaging labels Jul 31, 2018
@mhegazy mhegazy added this to the Community milestone Jul 31, 2018
@collin5
Copy link
Contributor

collin5 commented Aug 5, 2018

@DanielRosenwasser I would love to give this a try as my first PR. Any pointers to give me direction on this? Thank you!

@sandersn
Copy link
Member

sandersn commented Aug 6, 2018

@collin5 I would start by searching for the error message that you want to replace. Spaces are replaced by underscores in the code. Then add a case above that uses getTypeOfPropertyOfType, getSingleCallSignature, getMinArgumentCount and getTypeAtPosition to look for a method named get with a single string string parameter.

Two more things:

  1. diagnosticMessage.json is where you add error messages.
  2. tests/cases/compiler/ is where you add new test cases, which will add new baselines after a test run.

@collin5
Copy link
Contributor

collin5 commented Aug 8, 2018

@sandersn Thank you! Will open a PR for this soon.

@DanielRosenwasser
Copy link
Member Author

Thanks @collin5!

@collin5
Copy link
Contributor

collin5 commented Apr 30, 2019

You're most welcome 🙂.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants