mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Merge pull request #25433 from a-tarasyuk/bug/24839-give-a-better-error-message-for-using-import-as-a-type
24839 - Give a better error message for using import as a type
This commit is contained in:
@@ -9264,7 +9264,12 @@ namespace ts {
|
||||
resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
|
||||
}
|
||||
else {
|
||||
error(node, targetMeaning === SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName);
|
||||
const errorMessage = targetMeaning === SymbolFlags.Value
|
||||
? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
|
||||
: Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
|
||||
|
||||
error(node, errorMessage, moduleName);
|
||||
|
||||
links.resolvedSymbol = unknownSymbol;
|
||||
links.resolvedType = errorType;
|
||||
}
|
||||
|
||||
@@ -971,7 +971,7 @@
|
||||
"category": "Error",
|
||||
"code": 1339
|
||||
},
|
||||
"Module '{0}' does not refer to a type, but is used as a type here.": {
|
||||
"Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?": {
|
||||
"category": "Error",
|
||||
"code": 1340
|
||||
},
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
namespace ts.codefix {
|
||||
const fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
||||
const fixId = fixIdAddMissingTypeof;
|
||||
const errorCodes = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code];
|
||||
const errorCodes = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
getCodeActions: context => {
|
||||
|
||||
Reference in New Issue
Block a user