Skip to content

Commit 12bcf13

Browse files
author
Philipp Zins
committed
improve error message TS2307
1 parent f96c04c commit 12bcf13

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ namespace ts {
20072007
}
20082008

20092009
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol {
2010-
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0);
2010+
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_typings_for_this_module);
20112011
}
20122012

20132013
function resolveExternalModuleNameWorker(location: Node, moduleReferenceExpression: Expression, moduleNotFoundError: DiagnosticMessage, isForAugmentation = false): Symbol {

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@
976976
"category": "Error",
977977
"code": 2306
978978
},
979-
"Cannot find module '{0}'.": {
979+
"Cannot find module '{0}' or cannot find corresponding typings for this module.": {
980980
"category": "Error",
981981
"code": 2307
982982
},

src/harness/unittests/tscWatchMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ namespace ts.tscWatch {
183183

184184
function getDiagnosticModuleNotFoundOfFile(program: Program, file: FileOrFolder, moduleName: string) {
185185
const quotedModuleName = `"${moduleName}"`;
186-
return getDiagnosticOfFileFromProgram(program, file.path, file.content.indexOf(quotedModuleName), quotedModuleName.length, Diagnostics.Cannot_find_module_0, moduleName);
186+
return getDiagnosticOfFileFromProgram(program, file.path, file.content.indexOf(quotedModuleName), quotedModuleName.length, Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_typings_for_this_module, moduleName);
187187
}
188188

189189
describe("tsc-watch program updates", () => {

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,7 +3629,7 @@ namespace ts.projectSystem {
36293629
host.runQueuedTimeoutCallbacks();
36303630
diags = session.executeCommand(getErrRequest).response as server.protocol.Diagnostic[];
36313631
verifyDiagnostics(diags, [
3632-
{ diagnosticMessage: Diagnostics.Cannot_find_module_0, errorTextArguments: ["./moduleFile"] }
3632+
{ diagnosticMessage: Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_typings_for_this_module, errorTextArguments: ["./moduleFile"] }
36333633
]);
36343634
assert.equal(diags.length, 1);
36353635

@@ -3680,7 +3680,7 @@ namespace ts.projectSystem {
36803680
host.runQueuedTimeoutCallbacks();
36813681
diags = session.executeCommand(getErrRequest).response as server.protocol.Diagnostic[];
36823682
verifyDiagnostics(diags, [
3683-
{ diagnosticMessage: Diagnostics.Cannot_find_module_0, errorTextArguments: ["./moduleFile"] }
3683+
{ diagnosticMessage: Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_typings_for_this_module, errorTextArguments: ["./moduleFile"] }
36843684
]);
36853685

36863686
moduleFile.path = moduleFileOldPath;
@@ -3755,7 +3755,7 @@ namespace ts.projectSystem {
37553755
);
37563756
let diags = session.executeCommand(getErrRequest).response as server.protocol.Diagnostic[];
37573757
verifyDiagnostics(diags, [
3758-
{ diagnosticMessage: Diagnostics.Cannot_find_module_0, errorTextArguments: ["./moduleFile"] }
3758+
{ diagnosticMessage: Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_typings_for_this_module, errorTextArguments: ["./moduleFile"] }
37593759
]);
37603760

37613761
host.reloadFS([file1, moduleFile]);
@@ -3808,7 +3808,7 @@ namespace ts.projectSystem {
38083808
session.clearMessages();
38093809

38103810
host.runQueuedImmediateCallbacks();
3811-
const moduleNotFound = Diagnostics.Cannot_find_module_0;
3811+
const moduleNotFound = Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_typings_for_this_module;
38123812
const startOffset = file1.content.indexOf('"') + 1;
38133813
checkErrorMessage(session, "semanticDiag", {
38143814
file: file1.path, diagnostics: [{
@@ -5598,7 +5598,7 @@ namespace ts.projectSystem {
55985598
let diags = project.getLanguageService().getSemanticDiagnostics(root.path);
55995599
assert.equal(diags.length, 1);
56005600
const diag = diags[0];
5601-
assert.equal(diag.code, Diagnostics.Cannot_find_module_0.code);
5601+
assert.equal(diag.code, Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_typings_for_this_module.code);
56025602
assert.equal(flattenDiagnosticMessageText(diag.messageText, "\n"), "Cannot find module 'bar'.");
56035603
callsTrackingHost.verifyCalledOn(CalledMapsWithSingleArg.fileExists, imported.path);
56045604

0 commit comments

Comments
 (0)