Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
mhegazy merged 2 commits into
microsoft:mastermicrosoft/TypeScript:masterfrom
nowy:FIX-15540nowy/TypeScript:FIX-15540Copy head branch name to clipboard
May 19, 2017
Merged

Fix #15540: Throw error when importing @types#15866
mhegazy merged 2 commits into
microsoft:mastermicrosoft/TypeScript:masterfrom
nowy:FIX-15540nowy/TypeScript:FIX-15540Copy head branch name to clipboard

Conversation

@nowy

@nowy nowy commented May 15, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown

@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
Copy Markdown

@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

mhegazy commented May 15, 2017

Copy link
Copy Markdown
Contributor

@Andy-MS can you please review this change.

Comment thread src/compiler/checker.ts Outdated
return;
}

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

startsWith(moduleReference, "@types/")

Comment thread src/compiler/checker.ts Outdated

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
Copy Markdown

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.)

Comment thread src/compiler/diagnosticMessages.json Outdated
"category": "Error",
"code": 2710
},
"Cannot import type declaration files. Consider importing '{0}' instead of '{1}'.": {

Copy link
Copy Markdown

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

nowy commented May 16, 2017

Copy link
Copy Markdown
Contributor Author

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

@nowy

nowy commented May 19, 2017

Copy link
Copy Markdown
Contributor Author

@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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.