Fix #15540: Throw error when importing @types#15866
Conversation
|
@nowy, It will cover your contributions to all Microsoft-managed open source projects. |
3335ece to
1764ff9
Compare
Fix issue: microsoft#15540 - Modify checker; external imports to account for imported modules containing '@types/'. - Add diagnostic message. - Add test case
|
@nowy, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
|
@Andy-MS can you please review this change. |
| return; | ||
| } | ||
|
|
||
| if (moduleReference.substr(0, 7) === "@types/") { |
|
|
||
| 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); |
There was a problem hiding this comment.
Add a removePrefix helper like in #15545. (At the same place and with the same text, so that these PRs can merge together.)
| "category": "Error", | ||
| "code": 2710 | ||
| }, | ||
| "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'.": { |
There was a problem hiding this comment.
Put at 6137 near other module resolution diagnostics.
- Replace `substr` with `startsWith` - move diagnostics message to more relevant place - Add `removePrefix` helper function
|
@Andy-MS all done. Thanks for such a quick review! |
|
@Andy-MS when do you think this will this get released? |
Fix issue: #15540
containing '@types/'.
Fixes #15540