Skip to content

Remove always-incorrect error message about importing .ts extensions #52595

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
merged 3 commits into from
Feb 3, 2023

Conversation

andrewbranch
Copy link
Member

Fixes #52320

Hilariously, after recent resolution changes by me and Wesley, the message

An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.

only ever showed up when its suggestion in {1} does not exist. If it did exist, you would have gotten the message

An import path can only end with a '{0}' extension when 'allowImportingTsExtensions' is enabled.

So, the error message was literally always wrong, not just when allowImportingTsExtensions was enabled 🙃

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 3, 2023
@microsoft-github-policy-service

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary

==== /c.ts (1 errors) ====
import {} from "./thisfiledoesnotexist.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2792: Cannot find module './thisfiledoesnotexist.ts'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this correct error message when the file doesnt exist ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I actually didn’t look close enough at this one. This is weird; I think it’s only supposed to show up for non-relative names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this message just always comes up in classic, probably because classic is terrible and nobody should use it. It doesn’t make a ton of sense for relative imports, but honestly if someone is on classic it probably is a mistake, so I think we should leave it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allowImportingTsExtensions reports TS2691 instead of TS2307 for modules that cannot be found
3 participants