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

Fix #15540: Throw error when importing @types #15866

Merged
merged 2 commits into from
May 19, 2017
Merged

Conversation

nowy
Copy link
Contributor

@nowy nowy commented May 15, 2017

Fix issue: #15540

  • Modify checker; external imports to account for imported modules
    containing '@types/'.
  • Add diagnostic message.
  • Add test case

Fixes #15540

@msftclas
Copy link

@nowy,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@nowy nowy force-pushed the FIX-15540 branch 3 times, most recently from 3335ece to 1764ff9 Compare May 15, 2017 23:33
Fix issue: microsoft#15540

- Modify checker; external imports to account for imported modules
containing '@types/'.
- Add diagnostic message.
- Add test case
@msftclas
Copy link

@nowy, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, Microsoft Pull Request Bot

@mhegazy mhegazy requested a review from a user May 15, 2017 23:48
@mhegazy
Copy link
Contributor

mhegazy commented May 15, 2017

@Andy-MS can you please review this change.

@@ -1642,6 +1642,11 @@ namespace ts {
return;
}

if (moduleReference.substr(0, 7) === "@types/") {
Copy link

Choose a reason for hiding this comment

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

startsWith(moduleReference, "@types/")

@@ -1642,6 +1642,11 @@ namespace ts {
return;
}

if (moduleReference.substr(0, 7) === "@types/") {
const diag = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
error(errorNode, diag, moduleReference.substr(7), moduleReference);
Copy link

Choose a reason for hiding this comment

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

Add a removePrefix helper like in #15545. (At the same place and with the same text, so that these PRs can merge together.)

@@ -2135,6 +2135,10 @@
"category": "Error",
"code": 2710
},
"Cannot import type declaration files. Consider importing '{0}' instead of '{1}'.": {
Copy link

Choose a reason for hiding this comment

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

Put at 6137 near other module resolution diagnostics.

- Replace `substr` with `startsWith`
- move diagnostics message to more relevant place
- Add `removePrefix` helper function
@nowy
Copy link
Contributor Author

nowy commented May 16, 2017

@Andy-MS all done. Thanks for such a quick review!

@nowy
Copy link
Contributor Author

nowy commented May 19, 2017

@Andy-MS when do you think this will this get released?

@mhegazy mhegazy merged commit 4cd20b1 into microsoft:master May 19, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants