Skip to content

improve error message TS2307 #27054

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

Merged

Conversation

donaldpipowitch
Copy link
Contributor

Fixes "Improve error message for TS2307".

This pull request has no associated issue. I can't count how often I (or others in our office) misunderstood TS2307. Today was another day so I finally found the time to make this small PR.

TS2307 says Cannot find module '{0}'. and I (and others) often try to check if the module exists in the file system or not. If you use TypeScript as part of a complex build setup (e.g. within a webpack config) you often think some file cannot be found. But many times everything works fine and what is really missing is a type declaration for this module.

So that is what this PR is about. 🙃

Do I need to touch more files to update the translation or if I need to call a script to generate some files which depend on the message? Thanks!

@donaldpipowitch donaldpipowitch force-pushed the improve-error-message-TS2307 branch from 12bcf13 to 7965631 Compare September 13, 2018 05:46
@RyanCavanaugh
Copy link
Member

@DanielRosenwasser please follow up with this one; thanks!

@donaldpipowitch
Copy link
Contributor Author

donaldpipowitch commented Sep 27, 2018

I rebased with the current master to solve conflicts. Is this change fine for you?

Update: Meeh, build is broken. I try to fix it.

@donaldpipowitch donaldpipowitch force-pushed the improve-error-message-TS2307 branch 3 times, most recently from d8edd20 to fc88b40 Compare September 28, 2018 05:56
@donaldpipowitch
Copy link
Contributor Author

Dear future @donaldpipowitch,

because you always forget how you fixed something, I'll write it down.

  1. You tried to enhance an error message. In this case the message with error code TS2307.
  2. All error messages are located inside src/compiler/diagnosticMessages.json. Just search for the code 2307 and change the message from Cannot find module '{0}'. to Cannot find module '{0}' or cannot find corresponding type declarations for this module..
  3. The messages are used in snake_case without special characters in several places inside src/**. Search for Diagnostics.Cannot_find_module_0 and change it to Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module.
  4. Use VS Codes "Find and Replace" with regular expressions like this to fix the tests:
    • Find: Cannot find module '(.+?)?'\.
    • Replace: Cannot find module '$1' or cannot find corresponding type declarations for this module.
    • In: tests/**

@donaldpipowitch
Copy link
Contributor Author

CI has finished. @RyanCavanaugh or @DanielRosenwasser , it's fixed again 😍

@donaldpipowitch donaldpipowitch force-pushed the improve-error-message-TS2307 branch 2 times, most recently from d1d3f73 to 9552eec Compare October 24, 2018 07:39
@donaldpipowitch
Copy link
Contributor Author

@RyanCavanaugh or @DanielRosenwasser, I fixed the merge conflicts again. The CI partially errored, but the error message doesn't look to be related to my PR...? It also run without errors on Node 8 and 6.

Anything I can do on my side to get this merged? :)

@DanielRosenwasser
Copy link
Member

It's just on me; I don't check GitHub notifications as often as I used to but just update the baselines and we can get it in.

@donaldpipowitch
Copy link
Contributor Author

No problem, thank you very much. I'll fix this and give you a ping!

@donaldpipowitch donaldpipowitch force-pushed the improve-error-message-TS2307 branch from 9552eec to f5e8a18 Compare November 5, 2018 08:03
@donaldpipowitch
Copy link
Contributor Author

@DanielRosenwasser , it's green again. Thank you!

@donaldpipowitch donaldpipowitch force-pushed the improve-error-message-TS2307 branch 3 times, most recently from 5faec34 to a933da9 Compare November 11, 2018 20:13
@donaldpipowitch
Copy link
Contributor Author

Thank you for the feedback!

@donaldpipowitch
Copy link
Contributor Author

Conflicts again 😭

@donaldpipowitch donaldpipowitch force-pushed the improve-error-message-TS2307 branch from a933da9 to acb7cf9 Compare November 15, 2018 08:24
@donaldpipowitch
Copy link
Contributor Author

@DanielRosenwasser or @sheetalkamat : Can we merge this? ❤️

@DanielRosenwasser DanielRosenwasser removed this from the TypeScript 3.2 milestone Nov 29, 2018
@AndyRoyal
Copy link

TS2307 I rember you

@sandersn
Copy link
Member

sandersn commented Mar 5, 2020

Looks like this just needs a merge to be ready to go. @donaldpipowitch I'll get to it in the next few days if you don't first.

@sheetalkamat
Copy link
Member

@sandersn the unit tests folder has changed so the recent merge is bringing back some of the old files ..

@sandersn
Copy link
Member

@sheetalkamat how did they change? The one that I was aware of was moving src/compiler/testRunner/... up to src/testRunner/...
Are there others? I'll look for incorrectly re-added files there in the meantime.

@sandersn
Copy link
Member

ok, I think the 3 files in unittests, plus prettier's user test baseline, are all that were incorrectly re-added.

@sandersn sandersn merged commit e0f6ecd into microsoft:master Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants